- Home /
Smoothing Moves issue.
I'm coding a sort of Skeet launcher, so i have a "turret" wich given a number it turns in that direction and shoot. i'm using Quaternion.Slerp and everything works pretty good. the problem is: i can't figure out how to execute the turning slerp function until its end.
i'v tryed with a classic For Loop but it just skips to the end of the rotation..
this is the function
void SmoothAimingMovement()
{
Quaternion targetRotation = Quaternion.Euler(270, rotRandomY, 0);
Base.transform.localRotation = Quaternion.Slerp(Base.transform.localRotation, targetRotation, Time.deltaTime * smooth);
}
wich i am ofc colling in Update() on GetKeyDown. becouse if i use GetKey it also generates the random numbers all over again.
Can someone help me figuring it out? thank you :)
You cannot do multiple turns with Slerp(), so if rotRandY is >= 180 degrees, then you are only going to get the shortest distance to that rotation. You are going to have to use an alternate method...track your own turns and use Transform.Rotate() would be one choice.