I am writing a top-down space game.
I have a Ship Blueprint which contains The following Structure:
Here is my code that rotates moves the ship:
//Rotate Ship
FRotator ShipYaw = FRotator();
GetShipYaw(ShipYaw);
//ship->AddActorLocalRotation(ShipYaw * DeltaTime * 10);
//Move Forward
UPaperSpriteComponent* sprite = ship->FindComponentByClass<UPaperSpriteComponent>();
FVector shipForward = ship->GetActorForwardVector();
shipForward.Z *= 1;
shipForward.X *= 1;
//sprite->AddForce(shipForward * 1000000);
if (ShipYaw.Yaw > 0)
{
sprite->AddTorque(FVector(0.0, 0.0, -4000000.0));
}
else if (ShipYaw.Yaw < 0)
{
sprite->AddTorque(FVector(0.0, 0.0, 4000000.0));
}
If I call ship->AddActorLocalRotation() then the ship rotates and its forward vector updates, but visually nothing happens, so it’s mathematically correct but visually incorrect.
If I Add Torque to the sprite the sprite rotates visually but the forward vector does not update, so it’s visually correct but mathematically incorrect.
lol, I only need to get one of the two working
Any tips? I’m happy to post pictures of any of my code and/or settings. I’m just not sure where to dig.
Regards