Question about repositioning

hello, i got my physics engine working, and have the advanced car example



i have an working collision thest with an obstacle, and i want to put that obstacle on collision on the cars top



i want to set the obstacles localetranslation to the cars localetranslation plus an offset



but the effect is that it is flickering like hell, and the obstacle is inside the car …



how to re-position objects in a physics scene?

Basically you would do that as you indicated, but I dont know how your code looks. Using setLocalTranslation should work. You might have to call clearForces() on the phyiscsnode to avoid unintended forces after moving the node.

ok, it works now, i had to use clone() on the cars localposition before setting it for the obstacle, thx

Umm, you should be aware of the fact that when you use otherSpatial.setLocalTranslation(spatial.getLocalTranslation()) you actually reference the vector3f that stores the location in spatial. So their location will always be linked then.

Best way to do it w/o creating a vector for the garbage collector would be:

otherSpatial.getLocalTranslation().set(spatial.getLocalTranslation);