Spinning the Unit with Quarterions

I tried the turn using quarterion instead. Half of one and half of another I guess.

            case State.Aiming:
                Vector3 aimDirection = (targetUnit.GetWorldPosition() - unit.GetWorldPosition()).normalized;
                float rotateSpeed = 10f;
                Quaternion rotation = Quaternion.LookRotation(aimDirection);
                Quaternion current = transform.localRotation;
                transform.localRotation = Quaternion.Slerp(current, rotation, Time.deltaTime * rotateSpeed);
                break;

Loving the course by the way. I can already tell I’ll have to redo it a couple of times to have a decent grasp of the ideas here.

2 Likes

Yup that looks to be the way to do it with Quaternions, good job!

1 Like

Privacy & Terms