Hello.
I want to rotate object by z axis.
Here is my code.
[SerializeField] GameObject obj = default(GameObject);
float _lotationSpeed = 50f;
float _stopAngleZ = default(float);
// determine stop angle z (range: 0 ~ 360)
void StopRotate()
{
_stopAngleZ = 270f; // for example..
_status = GameStatus.Stopping;
}
void Update()
{
switch(_status)
{
case GameStatus.Rotate:
obj.transform.Rotate(Vector3.back * _lotationSpeed);
break;
case GameStatus.Stopping:
// TO-DO: rotate speed deceleration
// TO-DO: change status Stopping -> Stopped
break;
case GameStatus.Stopped:
// game end..
break;
}
}
I already search same name. But I can't find a solution.
How can I slowly stop to toward?
(! important, I don't want to reverse rotation, keep a same direction)
↧