The problem is, when my actor goes to fast up to the road , he is falling beneath it and it takes some time for him to be standing on the road again. If he goes slowly, than everything is fine.
I am using collisionHandlerGravity(), but it is the same with Floor() as well.
Can I keep him on the ground all the time somehow, no matter how fast he is moving?
I guess this has already been answered in one of the privious threads. You need to set the
base.cTrav.setRespectPrevTransform(1)
and change all of you actor-repositioning statement to type Fluid:
myActor.setPos(newx,new,y,newZ) becomes
myActor.setFluidPos(newx,newy,newz)
likewise,
myActor.setX(newx) becomes
myActor.setFluidX(newx)
This makes sure that even fast movement in the horizontal plane doesn’t cause your actor to move behind obstacles, as every point on his path is checked for collisions as he goes.
- Fred
Actually, I have a question about this myself:
Does the base.cTrav.resetPrevTransform() need to be called explicitly every loop in order for this to work properly?
Fred
base.cTrav.resetPrevTransform() does need to be called every frame, but you don’t need to call it explicitly, because this is already done for you by default. Check your task list; you should see a task called “resetPrevTransform”. This task is responsible for calling resetPrevTransform() so you don’t have to.
However, as the previous poster said, you do need to call base.cTrav.setRespectPrevTransform(1), once, to enable this mode.
David
it looks better, but still , when the road goes up and I am moving the actor with a very big speed, he goes under the road and then quicly gets back onto the surface . But the problm is, during that time when he is not on the road I can miss him at all, because he will be “travelling around the world now”.
Hmm, yes. This is a problem with both the CollisionHandlerGravity and CollisionHandlerFloor. They work by shooting a ray downward from the avatar’s current position to determine the distance to the ground. That works well for dropping your avatar down to the ground when he is above it, but is not so good for keeping him above the ground when he is below it.
One simple possibility is raising the starting point of your ray so that it is (for instance) 100 feet in the air above your avatar’s head. That way, if he pops under the ground for a bit, the ray will still detect this and put him right.
A better solution would be to use a CollisionHandlerPusher, with an associated CollisionSphere, in addition to your CollisionHandlerGravity. The pusher class is the only one that’s really good at keeping objects from moving through walls.
It would take a bit of finesse to get the pusher sphere and the floor ray to interact nicely together. You want the ray to have precedence over the sphere, so you should be sure to make the sphere small enough that it won’t reach the floor unless the avatar has already gone through it.
David