- Home /
Make a camera loosely follow an object
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.
Answer by lhk · Oct 31, 2010 at 11:17 AM
There are standard scripts that do what you want. Look at Mousesmoothfollow or Smoothfollow in the standard assets.
Your answer
Follow this Question
Related Questions
Camera movement in a Third Person Shooter Game 2 Answers
Point-and-Click Camera movement script 1 Answer
make camera move straight 2 Answers
Don'tDetroyOnLoad | issue 1 Answer
How can I freeze specific objects while camera is moving? 1 Answer