AddForce/AddImpulse won't work

Hey everyone,

I’ve created a Pawn class in C++, added a Mesh component and set physics simulation to true, as well as defining a physics profile to the Mesh (When I skipped this part, gravity wasn’t affecting the object). I used “Pawn”.

Now, I’m trying to AddForce on the Tick function, but don’t matter how big I make the force vector, the mesh simply won’t move.

The object is falling when I hit play, which means physics are being simulated, but Force/Impulse doesn’t get applied. I tried this both with Blueprints and C++.

When I use SetLinearVelocity, it works, but then gravity doesn’t affect the object.

I’m having a lot of issues with Physics with Unreal. Hope someone can help me out with this.

Here is my constructor code:

// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
// Setting the skeletal mesh to be the root.
mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh"));
RootComponent = mesh;

And here’s the Tick function:

Super::Tick( DeltaTime );
mesh->AddForce(mesh->GetRightVector() * 10000);

Pretty basic stuff which should be working fine, I think.

Well, if someone can give me a hand with this, I’d really appreciate.


Try This

mesh->AddForce(FVector::RightVector * mesh->GetBodyInstance()->GetBodyMass() * 1000);

Thanks, , it worked! now I’m trying to understand why. If I don’t multiply by the mass, it assumes it’s 0 and makes the whole thing a zero vector? Or the mass then makes the vector something that’s big enough in size?

myabe “mesh->GetRightVector()” is facing the ground

There is an other way to ignore the mass by enabling “Acceleration”

mesh->AddForce(FVector::RightVector * 1000,NAME_None, true);

Hi Thomas, I have a similar problem, I want to set velocity to my character, I have tried Mesh->SetLinearVelocity() and Mesh->AddForce(), I have followed your code, but still no motion, do you know why?