Collisionhandler in tunnel

Hello fellow scripters!

I am making a game where your caracter is flying with great speed through winding tunnels.
The game it self is working and controlling very nicely, but there is some collision problems.
When i fly into the wall i am using the collisionHandlerPusher and some times it lets me fly through the wall of the tunnel. This is a very big problem which I unsuccesfully have tried several hacks to get rid off. My quesition is - is there a better way of handling these collisions???

my collision code looks like this

class Collision1:
def init( self, myActor, tunnel):
self.i =0
#initialize traverser
base.cTrav = CollisionTraverser()

	#initialize pusher 
	self.pusher = CollisionHandlerPusher()
	self.myActor = myActor

	#create a collision solid for this model
	cNode = CollisionNode('playerCollNode')
	celleC = celle.attachNewNode(cNode)
	# show collision solid


	#add collision node to the traverser and the pusher


You need to turn on respectPrevTransform(). Just do this:


This tells the CollisionTraverser to consider the delta between your position this frame, and your position last frame, when deciding whether to report the collision. Without this setting, it is possible to pass completely over a collision polygon in the space of a single frame, and never detect the collision.

This setting is not on by default because there are some other implications that you should know about. First, turning this on means you do need to make sure that you are running the resetPrevTransform task (this is run by default on your main cTrav object, so no problem there). Second, when you reposition your avatar each frame, you should use setFluidPos() instead of setPos(). That is, you should use setFluidPos() when you are moving your avatar just a little bit, and you want to consider that it has moved through all the points in between (it is moving fluidly to its new position), and use setPos() when you are setting your avatar to a completely new position (for instance, into a new scene), and you want to consider that it has suddenly appeared there (it is a hand-of-God teleport, not the avatar moving itself).

The mode does automatically use a setFluidPos() to move your avatar, so again no problem there.

When you have your avatar’s collision sphere visible, you will see a ghosted sphere that lags a little bit behind your avatar’s position. This is representing the avatar’s previous frame’s position, and it is the delta between this ghosted sphere and the actual sphere that is used to compute the intersection test.


Thank you for making all my problems seem so simple… Wow now it’s working perfectly and my game is almost done!

Thanx a bunch!