Answers for "unity camera move with player"

9

camera follow

public Transform player;

    public Vector3 offset;

    void LateUpdate()
    {
        transform.position = player.position + offset;
    }
Posted by: Guest on June-11-2020
-2

how to code a move camera in unity

void Update()
 {
     if(Input.GetKey(KeyCode.RightArrow))
     {
         transform.Translate(new Vector3(speed * Time.deltaTime,0,0));
     }
     if(Input.GetKey(KeyCode.LeftArrow))
     {
         transform.Translate(new Vector3(-speed * Time.deltaTime,0,0));
     }
     if(Input.GetKey(KeyCode.DownArrow))
     {
         transform.Translate(new Vector3(0,-speed * Time.deltaTime,0));
     }
     if(Input.GetKey(KeyCode.UpArrow))
     {
         transform.Translate(new Vector3(0,speed * Time.deltaTime,0));
     }
 }
Posted by: Guest on August-03-2020

Code answers related to "unity camera move with player"

Browse Popular Code Answers by Language