Answers for "unity clamp"

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
3

mathf.clamp unity

//stops "value" from getting smaller than xMin and bigger than xMax.
float value = Mathf.Clamp(value, min, max);
Posted by: Guest on May-12-2021

C# Answers by Framework

Browse Popular Code Answers by Language