I'm trying to make the camera move in a set direction, but only when it has fallen behind a minimum distance to the player. I understand that I'm going to want to test to see if the camera's position is behind the player by a certain amount and only move forward then(I want there to be a bit of lag when the player uses their boost function. So far my script is like this:
var playerTracking : Transform ; var cameraSpeed = 6; var trackingDistance = 7;function Update() { playerTracking= GameObject.FindWithTag ("Player"); //if the camera is further away from the player than a certain distance, speed up. //camera just moves with the player
transform.position += transform.forward * cameraSpeed* Time.deltaTime;
}
How do I reference the position of the player and use that information in the way specified above? The bit I'm having trouble with is only moving forward when behind the player, to create that sort of catch-up effect.