I'm just working on something basic, and am trying to get a player controlled sphere to jump off a surface. I have a triangle mesh loaded up, as well as a few boxes and ball entities around. I want my ball to jump, while in contact with the ground, so when it leaves, it cannot jump and thus will not fly.
This is the simple jump code.
Code: Select all
public void Jump(Entity sender, Entity other, CollisionPair collisionPair)
{
if (g_Controller.GET.IsButtonDown(Button.RB))
{
g_NetworkManager.GET.ApplyForce(g_Constants.NetworkControllingPlayer, JumpForce);
}
}
Code: Select all
public void BuildDefaultBall()
{
this.BodyPhysics = new Sphere(MotionState.defaultState, g_Constants.PlayerMarbleRadius, g_Constants.GET.MarbleSettings.MarbleMass);
BodyPhysics.eventManager.addEventHook(new EventHandlerCollisionPairCollidingImmediate(Jump));
...
Also, after I get this working I would like to take into account the normal of the collision, so that when jumping off a slope, I will not leap straight up.
Anyway, any assistance would be appreciated.