Transform.RotateAround not rotating around specified game object.
I am trying to write a rotation script for my camera, so that it always looks at a player-controlled object (a simple movable hover car, for what it's worth). Currently, I've implemented a simple lag system so that there's a delay between the player moving and the camera moving, to make it look nice, basically. The target is set to the game object that the player controls. Here is my code:
public Transform target;
public float smoothSpeed = 10.0f;
public Vector3 offset;
void LateUpdate () {
float steerValue = (Input.GetAxis ("Steer"));
Vector3 desiredPosition = target.position + offset;
Vector3 smoothedPosition = Vector3.Lerp (transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
transform.position = smoothedPosition;
transform.RotateAround (target.position, Vector3.up, steerValue);
}
}
Without the transform.position = smoothedPosition line, the camera rotates around the game object fine. However, when I include that line, the RotateAround function just rotates the camera in-place, rather than around the game object, which is what I want. Is transform.position interfering with transform.RotateAround, or is there something I've overlooked? Is there a different process to rotate around a moving game object in Unity?