Question by 
               adrimat007 · Feb 21, 2016 at 04:27 PM · 
                cameraplayerfollowsmooth  
              
 
              problem ghosting camera with 2 objets
Problem whit camera if there 2 objets in the same view.
The problem if whit the second objet that follow the player , it got like big ghosting ( more in mi monitor 144hz than in the video ) but u just need to compare when the camera hit a border and not.
code(probly there if reduntant):
 using UnityEngine;
 using System.Collections;
 
 public class CamController : MonoBehaviour {
     
     private GameObject target;  // jugador // The player
     
 
 
     //Objetos donde choca  //Collision objets Camera 
     private GameObject TopWall;
     private GameObject DownWall;
     private GameObject LeftWall;
     private GameObject RightWall;
 
     private float TopY;
     private float DownY;
     private float LeftX;
     private float RightX;
 
     private Vector3  offset;
     
     void Start () {
         
         
 
         // medidas de distancia minima muros // Object and Distances Test
         target = GameObject.Find("Player_0");
         TopWall = GameObject.FindGameObjectWithTag("Top");
         DownWall = GameObject.FindGameObjectWithTag("Down");
         LeftWall = GameObject.FindGameObjectWithTag("Left");
         RightWall = GameObject.FindGameObjectWithTag("Right");
 
         TopY = TopWall.transform.position.y - 1.8f; 
         DownY = DownWall.transform.position.y + 1.9f; 
         LeftX = LeftWall.transform.position.x + 3.2f; 
         RightX = RightWall.transform.position.x - 3.2f; 
 
       
         offset = new Vector3(0f, 0f, -10f);
     }
     
     void Update () {
         
     }
     
     
     void LateUpdate()
     {
         // Camera.main.orthographicSize = Screen.height / 2 * 1 / 128; 
 
         if (target.transform.position.y > TopY)
         {
             if (target.transform.position.x < LeftX)
             {
                 transform.position = new Vector3(LeftX, TopY, -10f);
             }
             else if (target.transform.position.x > RightX)
             {
                 transform.position = new Vector3(RightX, TopY, -10f);
             }
             else
             {
                 transform.position = new Vector3(target.transform.position.x, TopY, -10F);
             }
         }
 
         else if (target.transform.position.y < DownY)
         {
             if (target.transform.position.x < LeftX)
             {
                 transform.position = new Vector3(LeftX, DownY, -10f);
             }
             else if (target.transform.position.x > RightX)
             {
                 transform.position = new Vector3(RightX, DownY, -10f);
             }
             else
             {
                 transform.position = new Vector3(target.transform.position.x, DownY, -10f);
             }            
         }
         else  if (target.transform.position.x < LeftX)
         {
             transform.position = new Vector3(LeftX, target.transform.position.y, -10f);
         }
         
 
         else if (target.transform.position.x > RightX)
         {
             transform.position = new Vector3(RightX, target.transform.position.y, -10f);
         }
         else
         {
             transform.position = target.transform.position+ offset ;
         }        
     }
 }
Here a video ; https://www.youtube.com/watch?v=gWls9RCxSFY&feature=youtu.be
Thx, and sorry my bad english :)
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
My model is shaking 0 Answers
Camera Follows 2D player 0 Answers
Camera Following [2D] 2 Answers
moving the camera smoothly to players current position in unity 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                