I had a task that updated the player position and consequently the camera while the player moved around the scene but I didn’t want to set its position when the player sphere collided with my collision mesh. The handlerPusher and my task caused the player to ‘kick’ the wall repeatedly.
I created another traverser with collisionHandlerQueue to detect the collision, when the sphere collided I set my variable self.collidionDetected to True to stop my task to continue updating the player position and to left no more than the handlerPusher to update the player position and it worked, the player is not kicking the wall anymore.
I don’t know collision handlers too much, my question is, is there a way to know when my sphere collide with my collision mesh with collisionHandlerPusher? to be sure, is it possible to associate more than only one handler with the traverser?
thank your attention! =)
You can listen for events with the CollisionHandlerPusher, but by the time you receive the event it will be too late: the pusher will have already pushed.
You cannot have both a CollisionHandlerPusher and a CollisionHandlerQueue handling the same object.
But the problem you are trying to solve might have an easier solution. If you ensure that the CollisionHandlerPusher always runs after your own movement task (but before the frame is rendered), then your movement task and the pusher should play nicely together. The pusher will only do anything if your movement task leaves the object partly embedded in a wall, and all it will do is move the object to the nearest safe spot outside of the wall–as if the wall were solid.
You can set the sort value of your tasks so that the collision traverser task is run after your movement task (which probably has sort = 0), but before the frame is drawn by the igLoop task (sort = 50). This is done for you automatically if you use the default base.cTrav object to handle the collision traversal; the default collision task is created with sort = 30.
thank you drwr!
my traverser traverses in the same task of the movement task, after myTrav.traverse(collMesh) I set the player position.
Well, trying doing that in the opposite order, then.
that’s it! =)