Answers for "unity clamp rotation around axis"

C#
4

unity clamp rotation

float rotationX = 0;
float rotationY = 0;
// you might also have some rotation speed variable
void Update() {
   rotationX += Input.GetAxis("Vertical") * Time.deltaTime;
   rotationX = Mathf.Clamp(rotationX, minRotationX, maxRotationX);
   rotationY += Input.GetAxis("Horizontal" * Time.deltaTime;
   transform.rotation = Quaternion.Euler(rotationX, rotationY, 0);
 }
Posted by: Guest on January-06-2020
1

rotation around own axis in unity

transform.RotateAround(transform.position, transform.up, Time.deltaTime * 90f);
Posted by: Guest on March-19-2020

C# Answers by Framework

Browse Popular Code Answers by Language