Hello,
I’m trying to make a a double jump, and I want to reset the player’s y velocity before applying the second jump. This is the code that I have so far, but it isn’t resetting the velocity.
I had a satisfying success by destroying and recreating a PhysicState
on the physic component.
On an actor, you do:
bool bRecreatePhysicState = false;
if (RootComponent)
{
RootComponent->ComponentVelocity *= 0;
if (RootComponent->IsSimulatingPhysics()) {
RootComponent->DestroyPhysicsState();
bRecreatePhysicState = true;
}
}
// anything you have to about its rotation, location or state
if (bRecreatePhysicState)
{
// false is to disable "bAllowDeferral" and force the engine to do it instantly
RootComponent->CreatePhysicsState(false);
}
It’s really intrusive, but less costy then deleteing and recreating the whole Actor IMHO.