I'm new to bepu physics, and I want to make a first person shooter in Xna. My player model will be a human, and I know how to make an entity and attach it to the model, add it to the space, blah blah blah. I first want to know how to move the player with physics and in the direction they are pointing (I tried to multiply the entitys world by a translation matrix, but when it moved the model, it went through the ground). Second, I want to know how to make it so that physics will apply on the x and z axis, but NOT the y axis, since in human shooters the person doesnt fall when they hit a small box).
Thanks
Moving 1st person
Re: Moving 1st person
This happens because setting the world transform (or setting the orientation or position) directly is a form of teleportation. Instead of moving dynamically to the new position, it snaps directly to the state with no respect for collisions or geometry. In the new invalid state, only the springy penetration correction can work. Additional teleportations can easily push an object through the world before correction can recover it.I tried to multiply the entitys world by a translation matrix, but when it moved the model, it went through the ground
To avoid this, objects should be moved with impulses and velocities, not teleportation.
Set the entity's LocalInertiaTensorInverse to the zero matrix. That gives the character essentially infinite rotational inertia. Nothing except direct developer intervention can cause such objects to rotate.I want to know how to make it so that physics will apply on the x and z axis, but NOT the y axis
To restrict certain axes, set the related row in the inertia tensor inverse to zeroes. However, for a character, I would recommend not allowing rotation around any axis. Doing so either allows them to fall over or to spin when they walk along walls. Directional control can be done without modifying the physical orientation of the character at all and considering it a pure game logic concept.
It sounds like you want a character controller. A robust CharacterController and SphereCharacterController are available in the BEPUphysicsDemos in the main source download. I would strongly recommend using them over creating a new one; they are tricky to get right.I first want to know how to move the player with physics and in the direction they are pointing
If you don't want full featured FPS motion, making an entity and controlling its velocity with the LinearVelocity property is a good start.