My route consists of a series of square (GeomNode) and on the left and right and I have 2 CollisionPolygon and 1 CollisionSegment representing the front of a car. I use these 3 things to detect off road event(I use a CollisionHandlerEvent) this work well.
Now I add to my game physics: I put a mass for the car and I want it to stay on the road (it goes up and decent) (with a gravitational force). To do this I create a CollisionPolygon for ground and CollisionSphere (which represents the car). I then use a PhysicsCollisionHandler.but I want separate the management of the collision left/right of the road and the physics (ground).
It’s possible?
Here is a screenshot:
I want to use the CollisionSegment for detecting off road/ lane changes.
and the CollisionSphere for keep the car on the road.
but now if the CollisionSphere touch the middle CollisionPolgon the PhysicsCollisionHandler works and I don’t want this because I want to change lanes (right-left and left-right) .
I want to know on which sqare the car is. It is possible to query the CollisionTraverser(or the PhysicsCollisionHandler) to know which square is colliding with the CollisionShpere (representing the car)?
I know the CollisionHandlerQueue store a queue of the current colliding node. The PhysicsCollisionHandler do the same job?
The PhysicsCollisionHandler does not store a queue. But it does trigger events whenever you start or stop colliding with a surface; and you can listen for those events and keep track of the current set of colliding objects yourself.
See the manual page entitled “Collision Handlers”, specifically the bit about CollisionHandlerEvent, for specifics about triggering events. Note that PhysicsCollisionHandler inherits from CollisonHandlerEvent, so it picks up all of this functionality. You may also find it helpful to use messenger.toggleVerbose() to enable reporting of all events generated, if you can’t find your collision event.