- Home /
 
 
               Question by 
               kyubi8 · Dec 31, 2017 at 03:21 AM · 
                cameraplayercamera-movementcamera follow  
              
 
              Camera and Player position
Hi i'm trying to have my camera follow the player but i need the player to stay behind a bit so the person playing can see ahead. Please see the images to see exactly what i mean. Bellow is the code i have for my camera:
  //following player
         private Vector2 velocity;
         public float smoothtimeX;
         public float smoothTimeY;
         public GameObject player;
     
     void Start()
     {
         player = GameObject.FindGameObjectWithTag("Player");
     }
 
  void FixedUpdate()
 {
             float posX = Mathf.SmoothDamp(transform.position.x, player.transform.position.x, ref velocity.x, smoothtimeX);
             float posY = Mathf.SmoothDamp(transform.position.y, player.transform.position.y, ref velocity.y, smoothTimeY);
 
             transform.position = new Vector3(posX, posY, transform.position.z);
 }
 
 ![alt text][1]
 
               
[1]: /storage/temp/108285-cap1.png
               Comment
              
 
               
              Your answer