Hi there;
I'm new to both Houdini Engine and Unity, so it's entirely possible the answer to the following question is "You totally don't understand what you're doing", but I'm gonna try anyway:
I've made a little thingy in Houdini, exported it as an HDA, and can bring it into Unity using Houdini Engine. I would like to make my thing animate, however. In Houdini, I would simply use $F to control this apparatus. I'm curious if I can do something similar in Unity, but I'm struggling to figure out how that might work.
I've created a top-level parameter on my HDA named, simply "ftime". I would like to drive this by something - anything - in Unity that is procedural (e.g. not keyframed). So, e.g. Time.deltaTime.
Without knowing any better, I've made a script in Unity, attached it to my Engine asset, and am now banging around trying to figure out how I might "plug" Time,deltaTime into my ftime parameter. I'm unsure how to find/address it, though, and unsure if this approach will even work.
Would anyone be willing to (gently) drop some knowledge on me, point me to a resource which exemplifies what I'm describing, or otherwise help untangle me?
Thanks, and happy holidays, fellow creators.
Animating a Houdini Engine asset in Unity
3233 3 1-
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
-
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
Hi again;
I figured something out, though it's almost assuredly not 'right' (which is to say: I doubt this is how this system was designed to be used). But, in case it helps anyone else who might read this:
--There's a folder of examples inside the Houdini Engine package within a Unity project's Assets folder, one of which is called "HEU_ExampleEvergreenQuery.cs" that offers some well-commented examples. Using this, I wrote the following:
This fundamentally works, though it's slow enough that I'm convinced it's not maximum awesome just yet.
I figured something out, though it's almost assuredly not 'right' (which is to say: I doubt this is how this system was designed to be used). But, in case it helps anyone else who might read this:
--There's a folder of examples inside the Houdini Engine package within a Unity project's Assets folder, one of which is called "HEU_ExampleEvergreenQuery.cs" that offers some well-commented examples. Using this, I wrote the following:
public class animateCrystal : MonoBehaviour
{
// This is a kloodgy way I'm connecting a standalone
// cs script to the Houdini Engine GameObject,
// and then connecting the GameObject to this script.
public GameObject houdiniGameObject;
// Start is called before the first frame update
void Start()
{
// probably should do something here, like maybe the asset query?
}
// Update is called once per frame
void Update()
{
HEU_HoudiniAssetRoot heuRoot = houdiniGameObject.GetComponent<HEU_HoudiniAssetRoot>();
// Query the gameObject
HEU_HoudiniAsset houdiniAsset = heuRoot._houdiniAsset;
// Set the ftime parameter
HEU_ParameterUtility.SetFloat(houdiniAsset, "ftime", Time.frameCount);
// Make sure to cook after changing parms
CookAsset(houdiniAsset);
}
public static void CookAsset(HEU_HoudiniAsset houdiniAsset)
{
// This starts a cook of the HDA, and waits until includes generation of output geomtry when cook has finished.
// See function comment for the various parms.
houdiniAsset.RequestCook(bCheckParametersChanged: true, bAsync: false, bSkipCookCheck: true, bUploadParameters: true);
}
}
This fundamentally works, though it's slow enough that I'm convinced it's not maximum awesome just yet.
-
- anthonyt2
- Member
- 100 posts
- Joined: Dec. 2020
- Offline
Hi, your code looks like its correct if you are trying to just change a parameter. HEU_ParameterUtility is deprecated though, but should stil work.
The more recent way to change a parameter and recook the asset in H19 is:
The more recent way to change a parameter and recook the asset in H19 is:
houdiniAsset.Parameters.SetFloatParameterValue("ftime", Time.frameCount, 0, true);
-
- dhemberg
- Member
- 207 posts
- Joined: Nov. 2015
- Offline
Amazing, thank you so much!
As an added note, to anyone else who may stumble across this thread: after upgrading Unity, the performance of this approach dramatically improved and the plugin now seems to run at near-realtime (or, at least as fast as it runs within Houdini itself, which is fine for my non-game-related intent).
As an added note, to anyone else who may stumble across this thread: after upgrading Unity, the performance of this approach dramatically improved and the plugin now seems to run at near-realtime (or, at least as fast as it runs within Houdini itself, which is fine for my non-game-related intent).
-
- Quick Links