Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private IEnumerator ScanRotateRange(float range)
- {
- var rotationSpeed = 100f;
- var initialRotation = transform.rotation;
- var rightRotation = transform.rotation*Quaternion.AngleAxis(range/2, Vector3.up);
- var leftRotation = transform.rotation*Quaternion.AngleAxis(-range/2, Vector3.up);
- while (transform.rotation != rightRotation)
- {
- transform.rotation = Quaternion.RotateTowards(transform.rotation, rightRotation,
- rotationSpeed * Time.deltaTime);
- yield return null;
- }
- while (transform.rotation != leftRotation)
- {
- transform.rotation = Quaternion.RotateTowards(transform.rotation, leftRotation,
- rotationSpeed * Time.deltaTime);
- yield return null;
- }
- while (transform.rotation != initialRotation)
- {
- transform.rotation = Quaternion.RotateTowards(transform.rotation, initialRotation,
- rotationSpeed * Time.deltaTime);
- yield return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement