Im trying to make some basic camera movements
How can I set it so the camera can't move below a certain y-axis value? I'm trying to make a Total War sort of camera. So I want to limit where the camera can move.
Also, I'm having an issue where the camera rotation speed stays the same, no matter what value I put it at.
Any help or tips for setting up a decent camera? Here's what I have so far...
public float moveSpeed = 50.0f;
public float tiltSpeed = 50.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate (Vector3.right * Input.GetAxis ("Horizontal") * moveSpeed * Time.deltaTime);
transform.Translate (Vector3.forward * Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime);
transform.Rotate (Vector3.right * Input.GetAxis ("Rotate") * tiltSpeed * Time.deltaTime);
}
Answer by MrMeows · Oct 22, 2015 at 12:38 AM
Remove the " = 50.0f" from the first two lines. I believe that is forcing those variables to always have a value of 50. Furthermore, the ".0f" is unnecessary. Integers are implicitly (automatically) converted to floats. As for giving the camera a minimum height...
public float minimumHeight;
if(transform.position.y < minimumHeight)
{
transform.Translate(0, minimumHeight - transform.position.y, 0);
}
Thanks so much, it worked :D
Do you have any tips for making the camera movement smoother? It feels a tad jittery.