I am trying to make a small plane fly. I already have a pawn, applied physics and now it falls to the ground and collides. Now I set up PlayerInput that would let the player apply a force by the press of a button. The problem is, when I press play and steer the plane in an upwards direction (by using AddTorque) the plane still gets pushed In a horizontal direction. What can I do to fix this and how do I apply the force correctly and locally? I tried using AddForceAtLocation, but then the pawn just started spinning uncontrollably.
This is my code:
void AMyPawnOne::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
InputComponent->BindAxis("PlanePitch", this, &AMyPawnOne::PlanePitch);
InputComponent->BindAxis("PlaneThrust", this, &AMyPawnOne::PlaneThrust);
}
void AMyPawnOne::PlanePitch(float AxisValue)
{
PlaneMesh->AddTorque(FVector(0.0f, -5000.0f, 0.0f)*AxisValue);
}
void AMyPawnOne::PlaneThrust(float AxisValue)
{
PlaneMesh->AddForce(FVector(5000.0f, 0.0f, 0.0f)*AxisValue);
}