Cannon rotation clamping
I am trying to make a cannon for my game that will rotate using the horizontal and vertical axis, I've tried many types of rotation, and I can get it to rotate but I can't clamp it. How can I clamp both the vertical and horizontal rotation of my cannon? Here's my code
public Transform cannonHead;
public float rotateSpeed = 100f;
float h;
float v;
void Update()
{
h = Input.GetAxis("Horizontal");
v = Input.GetAxis("Vertical");
}
void FixedUpdate()
{
cannonHead.Rotate(v * rotateSpeed * Time.fixedDeltaTime, h * rotateSpeed * Time.fixedDeltaTime, 0f, Space.World);
}
Comment
Your answer
Follow this Question
Related Questions
Rotation snapping to 180 degrees with transform.rotation 1 Answer
Rotating game object 1 Answer
Clamp transform.rotation? 0 Answers
Clamp transform.rotation? 0 Answers
My rotation is not the same in inspector as it is in the scirpt 0 Answers