{
public Transform target;
public float height = 7;
public float radius = 7;
public float angle = 0;
public float rotationalSpeed = 1;
void Update ()
{
float cameraX = target.position.x + (radius * Mathf.Cos(angle));
float cameraY = target.position.y + height;
float cameraZ = target.position.z + (radius * Mathf.Sin(angle));
transform.position = new Vector3(cameraX, cameraY, cameraZ);
if(Input.GetKey(KeyCode.A))
{
angle = angle - rotationalSpeed + Time.deltaTime;
}
else if(Input.GetKey(KeyCode.D))
{
angle = angle + rotationalSpeed + Time.deltaTime;
}
transform.LookAt(target.position);
}
}
This is the script I am working with but there are a few small issues with it.
1.) For some reason if the rotate speed is set to 1 and I press the key to turn the camera it moves extremely fast and far, the transition is not smooth at all. In fact its only about as smooth as I want it if I set the speed down to 0.05 which doesn’t seem right to me. Am I doing something wrong?
2.) when using the A key to rotate the camera it moves at one speed, but when I use the D key it moves at a much faster speed, about twice as fast or more. As far as I can tell this shouldn’t happen but it is, no clue why.
3.) if I want to change the keys for A and D to the arrow keys, what code do I use?
Any help at all on these issues would be great! Thanks