Hello,
This is my 1st post on this forum. I recently begin to use Houdini Engine in Unity. A friend of mine create assets within Houdini, giving me access to some parameters (called parms I guess?) that I can change in the inspector window of Unity.
To create a lots of differents things like rocks or trees by changing those parameters (scale, shape,…) it's just fine.
But I now would like to change thoses parameters that my friend gave me access to by using C# scripts in Unity. So that at runtime, when an event occurs, thoses parameters change. The only thing is I don't know how to call thoses parameters in a script? I looked in the “Houdini parms” script attached to the asset but did not manage to find where the parameters are defined.
If someone could help me that would be wonderful, thanks (btw sorry for my english, not my 1st language).
Changing houdini parms in runtime using C# scripts
6337 5 0- Krafter
- Member
- 3 posts
- Joined: May 2017
- Offline
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
Hi,
Unfortunately, the plug-in does not support cooking content at runtime (as this would require all users to have a Houdini License).
But you can use it for example, to bake multiple rocks or trees from an HDA, and then instance them at runtime.
A custom script that will randomize the parameter and bake the content can be used to automate that.
For an example of this, you can have a look at the HoudiniApiAssetAccessorExample.cs script in HoudiniApi/Scripts.
Unfortunately, the plug-in does not support cooking content at runtime (as this would require all users to have a Houdini License).
But you can use it for example, to bake multiple rocks or trees from an HDA, and then instance them at runtime.
A custom script that will randomize the parameter and bake the content can be used to automate that.
For an example of this, you can have a look at the HoudiniApiAssetAccessorExample.cs script in HoudiniApi/Scripts.
- Krafter
- Member
- 3 posts
- Joined: May 2017
- Offline
Hi,
Thanks for your answer. Too bad we can't!
I will look at the HoudiniApiAssetAccessorExample.cs script, I may have to ask some questions here after if it's ok with you, since I'm a beginner in code ^^“
Just to be sure about your answer : what is an HDA? ^^”
And so I can't cook content at runtime, but at runtime I can randomize and bake content then instantiate it, without having to save a lots of assets before and instantiate them at runtime?
For exemple my player enter a new zone, I can have a script saying “if zone = thisZone, scale of trees is a random number between 2 and 4” and bake and instantiate them at runtime?
Thanks for your answer. Too bad we can't!
I will look at the HoudiniApiAssetAccessorExample.cs script, I may have to ask some questions here after if it's ok with you, since I'm a beginner in code ^^“
Just to be sure about your answer : what is an HDA? ^^”
And so I can't cook content at runtime, but at runtime I can randomize and bake content then instantiate it, without having to save a lots of assets before and instantiate them at runtime?
For exemple my player enter a new zone, I can have a script saying “if zone = thisZone, scale of trees is a random number between 2 and 4” and bake and instantiate them at runtime?
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
Hi,
HDA = Houdini Digital Assets, that's the assets your friend are giving to you.
Unfortunately, baking content at runtime is not possible either (for the same reasons that cooking is not available at runtime), so you'll need to bake / save assets before and then instantiate them at runtime.
HDA = Houdini Digital Assets, that's the assets your friend are giving to you.
Unfortunately, baking content at runtime is not possible either (for the same reasons that cooking is not available at runtime), so you'll need to bake / save assets before and then instantiate them at runtime.
Edited by dpernuit - May 24, 2017 09:59:57
- Krafter
- Member
- 3 posts
- Joined: May 2017
- Offline
Hi, back after a while.
Oh ok I didn't get that I can't bake either Thanks for your answer.
Is saving a lot of assets like this expensive in term of ressources? If I put them in my game I guess it would be more heavy but maybe won't impact the performance needed by the game?
And you said :
I took a look into the HoudiniApiAssetAccessorExample.cs script in HoudiniApi/Scripts but did not manage to understand it ^^"
The script to randomize a parameter and bake content that you talk about, do I have to create it in Unity or in Houdini? Since you told me that I can't bake at runtime I have trouble to imagine how to do this script in Unity. Could you explain to me how to automatize this asset creation based on a HDA please? Sorry if my questions are unsophisticated, it's a new thing for me.
Oh ok I didn't get that I can't bake either Thanks for your answer.
Is saving a lot of assets like this expensive in term of ressources? If I put them in my game I guess it would be more heavy but maybe won't impact the performance needed by the game?
And you said :
But you can use it for example, to bake multiple rocks or trees from an HDA, and then instance them at runtime.
A custom script that will randomize the parameter and bake the content can be used to automate that.
I took a look into the HoudiniApiAssetAccessorExample.cs script in HoudiniApi/Scripts but did not manage to understand it ^^"
The script to randomize a parameter and bake content that you talk about, do I have to create it in Unity or in Houdini? Since you told me that I can't bake at runtime I have trouble to imagine how to do this script in Unity. Could you explain to me how to automatize this asset creation based on a HDA please? Sorry if my questions are unsophisticated, it's a new thing for me.
- seelan
- Member
- 571 posts
- Joined: May 2017
- Offline
Baking out an HDA to a prefab then instantiating it should not be any more expensive. It really depends on the resource though, and how many instances you've got going.
Back to your example:
“For exemple my player enter a new zone, I can have a script saying “if zone = thisZone, scale of trees is a random number between 2 and 4” and bake and instantiate them at runtime?”
Using this example, what you can do is expose the scale as an interface parameter in the HDA in Houdini. Bring it into Unity, then bake out a several trees of various scales. This gives you several prefabs, where each prefab can be for a particular zone. Then in each of your zone, place instances of a prefab. You could probably write a script that can populate a zone automatically at runtime by taking in a reference to the tree prefab, and a list of locations to instantiate them.
Before runtime though, you can even use something like the MeshDecorator to automatically instantiate those trees over terrain.
Eg.:
1. Create heightfield terrain and output as mesh HDA
2. Create Tree HDA
3. In Unity, bring in terrain and tree. Bake out terrain. Bake several versions of tree.
4. In Unity, use MeshDecorator and plug in terrain into Mesh Object, and tree as Instance_Object. Bake out your zone.
Back to your example:
“For exemple my player enter a new zone, I can have a script saying “if zone = thisZone, scale of trees is a random number between 2 and 4” and bake and instantiate them at runtime?”
Using this example, what you can do is expose the scale as an interface parameter in the HDA in Houdini. Bring it into Unity, then bake out a several trees of various scales. This gives you several prefabs, where each prefab can be for a particular zone. Then in each of your zone, place instances of a prefab. You could probably write a script that can populate a zone automatically at runtime by taking in a reference to the tree prefab, and a list of locations to instantiate them.
Before runtime though, you can even use something like the MeshDecorator to automatically instantiate those trees over terrain.
Eg.:
1. Create heightfield terrain and output as mesh HDA
2. Create Tree HDA
3. In Unity, bring in terrain and tree. Bake out terrain. Bake several versions of tree.
4. In Unity, use MeshDecorator and plug in terrain into Mesh Object, and tree as Instance_Object. Bake out your zone.
Edited by seelan - June 6, 2017 09:24:07
-
- Quick Links