BGE: Adding a maxJumps to the character controller to adjust how many jumps a character can perform before having to touch the ground. By default this is set to 1, which means a character can only jump once before having to touch the ground again. Setting this to 2 allows for double jumping.
This commit is contained in:
@@ -270,10 +270,10 @@ public:
|
||||
class CharacterWrapper : public PHY_ICharacter
|
||||
{
|
||||
private:
|
||||
btKinematicCharacterController* m_controller;
|
||||
BlenderBulletCharacterController* m_controller;
|
||||
|
||||
public:
|
||||
CharacterWrapper(btKinematicCharacterController* cont)
|
||||
CharacterWrapper(BlenderBulletCharacterController* cont)
|
||||
: m_controller(cont)
|
||||
{}
|
||||
|
||||
@@ -295,6 +295,16 @@ public:
|
||||
{
|
||||
m_controller->setGravity(gravity);
|
||||
}
|
||||
|
||||
virtual int GetMaxJumps()
|
||||
{
|
||||
return m_controller->getMaxJumps();
|
||||
}
|
||||
|
||||
virtual void SetMaxJumps(int maxJumps)
|
||||
{
|
||||
m_controller->setMaxJumps(maxJumps);
|
||||
}
|
||||
};
|
||||
|
||||
class CcdOverlapFilterCallBack : public btOverlapFilterCallback
|
||||
@@ -2320,7 +2330,7 @@ PHY_ICharacter* CcdPhysicsEnvironment::getCharacterController(KX_GameObject *ob)
|
||||
{
|
||||
CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController()->GetUserData();
|
||||
if (controller->GetCharacterController())
|
||||
return new CharacterWrapper(controller->GetCharacterController());
|
||||
return new CharacterWrapper((BlenderBulletCharacterController*)controller->GetCharacterController());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user