Rotate Between Two Angles - Unity Tutorial Basics

Published: 29 November 2020
on channel: Little Arch Games
9,643
159

Basic tutorial on rotating a gameobject between two angles in Unity. This is the easiest way I've found to rotate a game object between two angles back and fourth. There might be better ways to do this for your project but I find this way works for me. You can also serialize a field for the angle to move between and the starting angles so they are configurable in the inspector.


If you liked this, check out my game Escapea available on Android and iOS.
Android - https://play.google.com/store/apps/de...
iOS - https://apps.apple.com/us/app/escapea...


Thanks for Watching!


Script:


{
[SerializeField] float rotateSpeed = 60f;

void Update()
{
transform.localEulerAngles = new Vector3(0, 0, Mathf.PingPong(Time.time * rotateSpeed, 180) - 45);
}
}


On this page of the site you can watch the video online Rotate Between Two Angles - Unity Tutorial Basics with a duration of hours minute second in good quality, which was uploaded by the user Little Arch Games 29 November 2020, share the link with friends and acquaintances, this video has already been watched 9,643 times on youtube and it was liked by 159 viewers. Enjoy your viewing!