I am making a game where there is a tank that shoots some objects. I want to rotate the gun of the tank in between the llimits of -90 to 90 degrees in "X". I used transform.rotate but it rotates the gun with some float values (0.0 to 1.0) and the rotation I see on the inspector is something different. How to solve this issue?
Use below code from Mathf class
static float Clamp(float value, float min, float max);
e.g.
var angle = Mathf.Clamp(angle, 90, 270);
Quaternion target = Quaternion.Euler(0, 0, angle); // any value as you see fit
transform.rotation = target;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments