I have created a working prototype for a tank game. The final thing that I cannot get right is stoping the angle of the barrel at a set angle to stop it going stright up looking unrealistic or digging into the ground. My current script is
using UnityEngine;
using System.Collections;
public class TurrentMouseVert : MonoBehaviour {
public float horizontalSpeed = 2.0F;
public float verticalSpeed = 2.0F;
void Update()
{
float h = horizontalSpeed * Input.GetAxis("Mouse X");
float v = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (v, 0, 0);
//Debug.Log(transform.eulerAngles.x);
Debug.Log(transform.eulerAngles.y);
//Debug.Log(transform.eulerAngles.z);
}
}
I have removed my test part that included mathf.clamp to avoid confusion, please help