Search - User list
Full Version: How do I access the bounding box of the first instanced object?
Root » Houdini Engine for Unity » How do I access the bounding box of the first instanced object?
Erik_Ostsjo
Hi everyone! First post on this forum .

I've a question regarding instancing in unity. In this example I want to instance a unity game object along a line. I want the number of points on this line to be determind by the bounding box size of said unity game object. So if the line is 10 units long and the object is 1 unit wide, 11 objects will be instanced along the line. How would one achive something like this with only the instance input in unity?
seelan
For something like this, I would just use a curve, then instance along the curve points. There is a neat shelf tool that the plugin ships with called Curve Instancer that does just this. You can find that by opening HoudiniEngine menu > Houdini Engine Tools. Open that in Houdini to see what its doing.

You can also add in another input into your HDA that takes in a geometry (bounding box), then based on its size, creates number of points, and instances along those points.

But if you are stuck with just the single instance input, are you able to set the number of points from within Unity? Not sure how you are defining your line, but you can calculate the number of points based on the bounding box size in Unity, and if the point count is exposed as a parameter then you can set it via script. Seems kinda limiting so not sure what you're trying to do.
Erik_Ostsjo
Hi again! Thanks for the answer!
Sorry about the late reply. I had to put the project on ice for a couple weeks but now I'm back!

My original problem was that I didn't know what type of objects my level designers wanted to place along the line/curve in unity. So to make sure they didn't leave gaps or intersect with each other along the curve, I had to somehow measure the size of the object that the level designer put into the “instance input” in unity. Since we have to use instanced prefabs and can't use geometry output from houdini. I couldn't figure out how to get access to and measure the object that was put into the “instance inputs” slot.
How to do this is what I wanted to figure out with my original question.

Meanwhile I added a secondary input to the HDA in the form of an “object input” under “asset parameters”. This input was purely so that the HDA would be able to measure the object before passing the data to the points on which I then instanced the same objects prefab. Ofcourse this was a very poor solution since for each new prefab that our level designers wanted to place, they had to place it in two different slot otherwise the asset wouldn't work correctly.

Since then I've found a way to auto create and populate the “instance inputs” from just placing the prefab in the object input. (see gif).

Don't know it helps anyone but just in case. My solution was to create “instance inputs” by using the code:
s@unity_instance = prim(2,“unity_input_mesh_name”,0);
in a wrangle within a for loop that went through each object in the “Object input” by their “unity_input_mesh_name”
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB