Pawn Pitch Rotation of 360 Degree

Hi there,

My Pawn (a plane) should be able to fully rotate in all values(roll, yaw, pitch) from 0 to 360 degree.
Normally I just use AddActorLocalRotation(DeltaRotation, true), but the pitch value likes only values from -90 to 90 degree.

After I red threads like https://answers.unrealengine.com/questions/36110/rotate-a-pawn-in-full-360-degrees.html ,
I am aware, that there are problems with gimbal lock.

So my questions:

  1. If I want to use that FORCEINLINE function, do I have to put in the cpp file of my pawn or in a specific class of the engine?

  2. How is this problem solved? (euler degrees, quaterions, different approaches?)

  3. Is there another way, where a FORCEINLINE or quaternions aren’t needed?

Greetings

Hi,

  1. You have to add this function in your Pawn class and call it when you want to rotate your Pawn.
  2. The best way to solve this is quaternions.
  3. FORCEINLINE specifier instruct the compiler to insert a copy of the function body into each place the function is called. This is not necessary but this optimize your code and make it faster.

Hi, thanks for the info :slight_smile:

I’ve put the function into my Pawn.h and called it within my Pawn.cpp
Even though I’m updating my pawn’s rotation now this way, I still cannot go over a pitch of 90°.

I’m asking myself if some updates to the camera have to be done as well?
Anyway thanks for the help :slight_smile:

Hi,

Try this code

void ATestActor::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	auto rot = GetActorRotation();

	FQuat q1 = FQuat(rot);
	FQuat q2(FVector(1,0,0), 0.2*DeltaSeconds);
	FQuat qr = q2*q1;

	SetActorRotation(qr.Rotator());
}

Best regards,