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;
mesh->SetSimulatePhysics(true);
mesh->SetCollisionProfileName(TEXT("Pawn"));
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.
Thanks!