place an object on another object

I have a box and I want to place an object (instanced mesh) randomly on that box, but its not allowed to be placed inside the box, only on the “outline”.
First I thought that I would create another box that’s just a tiny bit smaller than the original box, and then get the value between those two boxes and randomly place the new object there.
But I realized that I don’t know what nodes to use and/or what to search for.

Any help? Is there a better and/or easier way to do this?

1 Like

If you use a line trace, you can get the impact point and normal

lt

Will this work in a construction script?

1 Like

Yes, but I don’t quite get your concept.

Do you mean randomly place little cubes on a big one, for instance?

Yes exactly.
(Like how BlenderGuru shows how to place sprinkles on a dount in blender with geometry nodes)

  • you could line trace from the outside towards the box (from the top)
  • you could sweep - overkill for boxes but may be needed for irregular shapes
  • you could math it out with component bounds:

50% chance to place a box on top


to place sprinkles on a dount

Line trace, get normal and use components bounds to shift the sprinkle along the normal.

cubes

image

4 Likes

Thank you! This works, but If i have another object close to the big box it will add small boxes to that too

Yes, it will :slight_smile:

You could add the other object to the ‘ignore list’

image

Or you could use custom collision channels to avoid it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.