0
$\begingroup$

It may be simple but I don't get it to work. I have ground objects and several other objects that should stand on the ground. These other objects are automatically positioned. The x,y coordinates are fixed here, but the z coordinate has to be adapted so that the objects really stand on the ground.

What is the best option here? Use object.ray_cast or search for nearest vertices in the area of x,y?

$\endgroup$
3
  • 3
    $\begingroup$ It would help if you posted your script. $\endgroup$
    – Rick T
    Commented Nov 24, 2020 at 3:09
  • $\begingroup$ Could be finding the lower vertex in z, from the plane or world point of view. Could you illustrate the situation with some images? $\endgroup$
    – lemon
    Commented Nov 25, 2020 at 17:55
  • 1
    $\begingroup$ Related blender.stackexchange.com/questions/174727/… $\endgroup$
    – batFINGER
    Commented Nov 26, 2020 at 3:38

1 Answer 1

1
$\begingroup$

Precisely speaking you need some sort of collision detection look at this book and this link for more info.

Roughly speaking ray casting is a good way; but be careful about optimization.I suggest you to compare x-y bounding boxes of your objects and groundObjects (using bpy.data.objects['Cube'].bound_box ). If they overlap each other do raycasting for each vertex of your objects on the overlapping groundObjects and choose the shortest one.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .