Download

Do you use Quarternions? [Fixed!]

Had I not been using Physics to set the Angular Velocity it certainly would have been easier, but I had to set the rotation purely with SetPhysicsAngularVelocity. Ah well, works just fine now!

Hey, new here but I’m running into a similar problem and wondering if you (or someone, I know this thread is real old) can help enlighten me as to what I’m doing wrong.

Essentially I have a spaceship that I would like to rotate based on player input. I want to locally rotate with pitch and yaw only but as you described I’m getting a small amount of roll when I would like to maintain the previous roll of the actor.

I’ve tried a bunch of different methods mentioned in this thread and many others but to no avail. Here’s a couple things I’ve tried:



FQuat curQuat = AShipCode::GetActorQuat();

FQuat q = FQuat(AShipCode::GetActorUpVector(), AShipCode::YawSpeed * (PI / 180) * DeltaSeconds);
curQuat = q * curQuat;

q = FQuat(AShipCode::GetActorRightVector(), AShipCode::PitchSpeed * (PI / 180) * DeltaSeconds);
curQuat = q * curQuat;

AShipCode::SetActorRotation(curQuat);




AShipCode::AddActorLocalRotation(FRotator(AShipCode::PitchSpeed * DeltaSeconds, AShipCode::YawSpeed * DeltaSeconds, 0));


The only method I can get to work is to set the roll to 0 after adding/setting the rotations. This works fine when my starting roll is 0 but the plan is to add another user input for indepedently modifying roll so it’s not an acceptable solution for me.

Only adding one of yaw or pitch works fine but as soon as I add the other, some small roll gets introduced.

Any help with this would be wonderously appreciated :slight_smile: