Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Camera follow player

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 318
    Comment on it

    Add a new script to Main Camera of your scene.

     

    public class CameraController : MonoBehaviour
    
    {
    
       public GameObject player; // add your player object in the tool
        
        private Vector3 offset;
        
        void Start ()
        {
            offset = transform.position - player.transform.position;
    
    //  offset is used for storing the difference between your scene camera position and your player position
       }
        
        void LateUpdate ()
        {
            transform.position = player.transform.position + offset;
    
        }
    
    }
    
    //here we are changing the position of camera according to the player movement. It means, wherever your player move your camera will follow it.


       

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: