First of all, I assume that you aren’t using the built in CollisionHandlerPusher (which incidentally throws events as well, since its a child of CollisionHandlerEvent)
So lets run through the steps of what’s going on here:
You have some keyboard events that move your character
When you press the keys, it renders you inside the bounding volume, then pushes you out the next frame.
Anywho, lets chart this out based on the taskManager priorities
dataLoop -> -50
eventManager -> 0
yourLoop -> 0
collisionLoop -> 30
igLoop -> 50
These are the major players here.
Now, lets run through case, where the “w” key moves you into the wall
event “w” is thrown, to be picked up by eventManager
dataLoop is the lowest priority task on the list above, so it gets called first
(note: task with the same priority are called in the order they were added). The dataLoop sees that the “w” key was pressed, and so it throws the event “w”
eventManager is called sometime after that. It receives the event, then routes it to one of your functions that sets the state of your avatar (in this case, “walk forward”)
now yourLoop is called, which will move the dude forward into the wall.
Moving on, we come to the collisionLoop. It sees the dude colliding with the wall, and sends and event “dude-hit-wall” or something.
Finally we come to igLoop, which will render the scene. Since we’ve allready gone through the eventManager task this frame, the “dude-hit-wall” event won’t be processed until the next frame
So what can you do about this?
- One thing to try, though it could have wierd results:
#tell the event manager to do another event pass.
#add the new frame event to the end, in case anything comes after
Again, this may have unwanted side effects, but it will ensure that the events get processed.
- Another way that might work:
taskMgr.add(self.afterCollision,"after collision Task",priority=35)
#first check to see if we didn't hit anything
#keep in last position
#the new position is good, move it there.
#store away the last position
#move to new position
#store away the new position as well
#reset the position to the last known "good" position
#your accepts point to functions like this