- Home /
Smooth Camera Follow
I done a simple code of a Camera Follow to a 2D Platformer, but i want to add a little delay on the follow, how can I do this ? It's possible on my code ?
using UnityEngine;
using System.Collections;
public class CameraScript : MonoBehaviour
{
public Camera mainCamera;
public GameObject player;
void Update ()
{
mainCamera.transform.position = new Vector3(player.transform.position.x, player.transform.position.y,transform.position.z);
}
}
Answer by DMCH · Sep 10, 2013 at 09:45 PM
One possibility is to make a (camera tracking) gameobject which will follow the player if the distance between the player and the game object is greater than a certain amount. When this amount is exceeded, get the object to follow the player until it catches up. Then, instead of getting the camera to follow the player, get it to follow this gameobject.
You could gradually increase the speed at which this gameobject moves to allow it to catch up, then reset it when it catches up.
I've never actually done this, so it's hard to say how well the implementation would work.
Hmm, that's looks nice idea, will try that tonight and answer you back, thank you
Answer by flaviusxvii · Sep 10, 2013 at 09:20 PM
iTween has lots of utilities for smoothing movement.
I looked on iTween but don't found anything that I need to use, looked at documentation, and scenes, but nothing was useful =/
I don't forgot you guy, tonight I will try that and if work I will response here
Your answer

Follow this Question
Related Questions
Why does the camera smoothly follow in one direction but not the other? 0 Answers
How to smoothly move a 2D camera without ghosting 3 Answers
Map level selection slide smoothly 3 Answers
Smooth Camera 2D 0 Answers
The sprite that is being followed by thr camera is very jittery and doesn't look very nice at all. 2 Answers