How can I avoid Gimble lock when adding 2 rotators

Hi I am trying to create a create a projectile system. It includes the projectile going in a Sinwave.

The problem is it includes adding 2 rotators. When the projectile is shot towards the sky or towards the ground, according to my guess, it gets gimble locked and patterns gets closer.

Is there any way to avoid it?

In udk there was a function RTransform() to get around it.

I am using something like this

	if (directionturn == 1)
	{
		Rotation+= FRotator(45, 0, 0);
	}
        InitialVelocity = ProjectileMovement->Velocity;
	ChangeVelocity = Rotation.Vector();

Then in a tick function do this

ProjectileMovement->Velocity = InitialVelocity + ((SinVelocityMultiplier * ProjectileSpread) * ChangeVelocity);

The function is more complicated then this. I have written it in simpler way

There is a method to do it using Quats. But I am not sure how is it done.

#FTransform

If you wanted to do this for character or component:

RV_Transform = CurrentWeaponSkelMesh->GetRelativeTransform();
RV_Transform.ConcatenateRotation(AddRot.Quaternion());
CurrentWeaponSkelMesh->SetRelativeTransform(RV_Transform);

#For Velocity

You can still use the FTransform for just rotation changes

   FTransform RTrans(YourStartingRotation);
  RTrans.ConcatenateRotation(FRotator(45,0,0).Quaternion());
  ChangeVelocity = RTrans.Rotator().Vector();

#Summary = FTransform.h

Study the entire FTransform class in and out and you will be very happy with what you find there :slight_smile:

Rama