Rotate Between Two Angles - Unity Tutorial Basics

Publié le: 29 novembre 2020
sur la chaîne: 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);
}
}


Sur cette page du site, vous pouvez voir la vidéo en ligne Rotate Between Two Angles - Unity Tutorial Basics durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Little Arch Games 29 novembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 9,643 fois et il a aimé 159 téléspectateurs. Bon visionnage!