Tank turret rotation

Hi Guys.
I have reay weird proble with my tank. When I am aiming at the right side of the tank everything is fine, but when I am moving aiming point to the left at some poit it starts to rotate right again. So it goes to -60 degrees and the starts rotating oposite direction, beeing stuck in some places. Does anyone have similar problem?
Thank you for your help!

Then it goes round like idiot

Covered later but you can just use

if (FMath::Abs(DeltaRotator.Yaw) < 180)
{
	Turret->Rotate(DeltaRotator.Yaw);
}
else // Avoid going the long-way round
{
	Turret->Rotate(-DeltaRotator.Yaw);
}

Or I believe someone said you could use GetNormalized so

if (DeltaRotator.GetNormalized().Yaw < 180)
{
	Turret->Rotate(DeltaRotator.Yaw);
}
else // Avoid going the long-way round
{
	Turret->Rotate(-DeltaRotator.Yaw);
}

Thank you for your fast answer. If it’s covered later I will watch the lectures then.
I was trying to solve problem by myslef, but couldnt find any solution.
Thank you :slight_smile:

Privacy & Terms