top of page
Search

Unity Practice

  • Writer: Keshav Batra
    Keshav Batra
  • Sep 23, 2022
  • 1 min read

I've decided to continue with the unity lessons and work on getting this vehicle moving from one place to another. I did this by watching the videos and then doing the task.



FollowPlayer script:



 public GameObject player;
    private Vector3 offset = new Vector3(0,3,-7);

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void LateUpdate()
    {
        //Offset the camera behind the player by adding the player's position
        transform.position = player.transform.position + offset;
    }

Player Controller:


public float speed = 5.0f;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //Moves the vehicle forward 
        transform.Translate(Vector3.forward * Time.deltaTime * speed); //the variable is multiplying by speed which equals 5
    }

 
 
 

Comentários


bottom of page