Allow me to explain a bit. This code is inside a class that inherits from NodePath. It’s basically an actor with move forward/backward and turn left/right methods. The nodePath looks something like this:
CollisionNodePath(“agentSphere”) # used for wall collisions
CollisionNodePath(“agentRay”) # used for floor collisions[/list:u][/list:u]
I did it this way so I could implement physics effects using an ActorNode. Those are currently disabled at the moment so I can focus on basic collision handling.
Right now I create a new Agent (my custom class), and setZ(10) so that he’ll fall on the floor. But instead, he falls right through the floor into infinite. What could cause this?
I’m already calling base.cTrav.setRespectPrevTransform(True). I’m not sure what base.floor is used for. Any ideas?
I don’t see anything obviously wrong in the snippet you pasted.
There’s no such thing as base.floor by default, so if you have a base.floor, it must be something that you have created. From the code you pasted, it must be a CollisionHandler of some kind, presumably a CollisionHandlerFloor. (Note that a CollisionHandlerFloor won’t normally drop your object to infinity; if the object is not over a floor, it won’t move it at all.)
It certainly does if you’re referencing it, as in the above snippet. If you’re not getting an error, and you haven’t defined base.floor somewhere else, are you sure you’re actually running that code?
Yep. You’ll need a completely different system if you plan to use the physics engine. The CollisionHandlerFloor is only for non-physics based simulations. I think you’d probably want to use a PhysicsCollisionHandler instead, and you would attach this to your sphere, not to any ray. You wouldn’t use a ray at all in a physics-based simulation.
Sorry, I forgot to mention this. The function where this is called takes in a collisionTraverser as an argument. I use that in my real code instead of base.cTrav. In a similar way, my CollisionHandlerFloor in my real code is defined right above where I use it:
joem86, if you just need to make a walk-run-jump avatar game, there is a much simpler solution that is the neat GravityWalker module that will take care of all the physics hassle. If you wanna diggin into, download here the sample.zip package (in the first post of the thread) and you’ll find, besides other useful samples, the gravitywalker one in the camera folder with also .blend sources to see and learn how to build your scene properly.