Hello Community!
I'm wanting to launch my character (as if it were jumping) and I'm unsure how to do so. I've tried to take a look at GetPhysEntity(), but there's nothing about "impulse" or "Velocity" or nothing. I have a bind on the spacebar to have the player jump and stored a pointer for the character but, like I said, just need to know how to launch the character.
bool CPlayerInput::OnActionJump(EntityId entityId, const ActionId& actionId, int activationMode, float value) { if (activationMode == eIS_Pressed) { auto *pCharacter = GetEntity()->GetCharacter(CPlayer::eGeometry_ThirdPerson); if (pCharacter != nullptr) { //JUMP CODE HERE } CryLog("JUMP"); } return true; }
Cheers!
Answer by ArcticLion-1 · Nov 08, 2016 at 07:38 AM
try this:
bool CPlayerInput::OnActionJump(EntityId entityId, const ActionId& actionId, int activationMode, float value)
{
if (activationMode = eIS_Pressed)
{
IPhysicalEntity* phys = GetEntity()->GetPhysics();
if (phys)
{
const float power = 300.0f;
const Vec3 dir = Vec3(0.0f, 0.0f, 1.0f);
pe_action_impulse impulse;
impulse.impulse = dir * power;
phys->Action(&impulse);
}
}
return true;
}
This works great!!! I should look more into IEntity and understand what attributes it all has. @ArcticLion-1 Thank you again!