Rotating actor up and right relative to Roll angle

I’m doing a ship in space and you can rotate it up, down, left and right to modify the direction in which is going, i’m doing that with Pitch and Yaw, but it also has a roll that i do with the Roll axis, but of course after rolling to an angle Pitch and Yaw are no longer in sync with the Up and Right of the ship, what i want is to be able to still rotate up, down, left and right relative to the Roll so that it always rotates in the direction of the deck and bottom when rotating up and down,  and to the wings when doing left and right.
What can i do to make that possible?

Sure here it is:

void APlayerCar::Tick(float DeltaTime)
    {
    	Super::Tick(DeltaTime);
    	SetActorRotation(GetActorRotation() + lookAt * DeltaTime);
    }
    
    void APlayerCar::Right(float axisValue) {
    	lookAt.Yaw = axisValue * rotateSpeed;
    }
    
    void APlayerCar::Up(float axisValue) {
    	lookAt.Pitch = axisValue * rotateSpeed;
    }
    
    void APlayerCar::Rotate(float axisValue) {
    	lookAt.Roll = axisValue * rotateSpeed;
    }

The Right, Up, and Rotate functions are called on a blueprint after input.

Hey there, the idea is to add movement based on the relative rotation of the mesh and not the world, can you show me your movement code?

Ok so you are using world actor rotation and that’s going to be a problem, if you roll the ship 45º to left and press up, he’s probably still going up and not diagonally. Try using ShipMesh->GetComponentRotation() instead of GetActorRotation.

Yeah exactly, still meshComp->GetComponentRotation() did not do it, also tried it with root component instead of the mesh and nothing.

Changing the rotation to a quaternion system fixed the problem.

Good to know :slight_smile: