I have an attack in my game where the character stops in the air and starts falling down. I need to make sure that the momentum is extinguished in the air, as if the character collides with a wall.
Would this work?
USceneComponent* Component = MyActor->GetRootComponent();
if (Component != nullptr)
{
Component->SetAllPhysicsLinearVelocity(NewVelocity, false);
}
I use the Blueprint system, and I don’t really know about the nuances of programming for UE4 in C++, can you translate what does GetRootComponent mean?
Ah, sadly I have barely touched the blueprint system. But essentially I have accessed the Actors Root Component, and Set it Velocity to “NewVelocity” which ofc can be Vector3(0,0,0) if you want. it will stop dead there I believe (overriding the velocity calculated in the physics engine). I expect that the blueprint system can also access the function “SetAllPhysicsLinearVelocity” or perhaps just the actual velocity value itself.
Sorry I couldn’t be of more help.