I am trying to place some stuff on the ground of “Tut-Roaming-Ralpy.py” sample came with package.
I tried to use “CollisionHandlerFloor” & “CollisionRay”, but I fail due to lack knowledge of those.
Can someone give me some tips to get this work?
Those stuff are just place on the grond (not a flat ground) and won’t move at all.
In general, if I’m placing static objects in the world that will never be moved, I do it by hand by loading the object and then doing myLoadedModel.place() to bring up the placer dialog.
But to place it automatically using the collision engine, your approach is on the right track. The objects you’re placing will all need to be From objects, and the CollisionHandlerFloor needs to be notified of what object it is moving (similar to CollisionHandlerPusher, etc.). You may also want to check that the From collision mask on the ray matches the Into collision mask on the ground surface.
It should be noted, however, that this is a somewhat inefficient solution; the From objects will be checked every frame for collision solution, but this isn’t necessary if they never move. A more elegant solution might be to position your collision ray at the X,Y coordinates of the object, then run a collision pass and determine the point of intersection (using a CollisionHandlerQueue and the CollisionEntry.getSurfacePoint method). This will give you the Z-coordinate of the ground surface at that point, which you could record into your model. That way, you need only check the position of every object one time.
This is all a very high-level overview of the techniques; if you want a clarification, feel free to ask.