Unity Tutorial 02

 


Image of the vehicle from the tutorial

For this weeks task I had to continue on with the unity tutorials from last week. This week I learned how to control the vehicle and make it move from left to right rather than the vehicle just going straight and driving off the end of the path. First I had to open my PlayerController script and add a public float variable called a turnSpeed. I gave it a speed of 5.0f just like in the tutorial.  I also had to add a new vector3 in the transform.translate section of my script. Earlier in the tutorials I had to add vector3.forward to my transform.translate section but now to make the vehicle move left and right I had to add vector3.right and vector3.left so now the vehicle can move left, right and forward. I then had to multiply the Time.deltaTime by the turnSpeed variable so that so then the vehicle could turn left and right overtime instead of once every frame. After I did this we then had to go into the input manager in project settings. This is so that once the game is completed the player playing the game actually has control over the vehicles movement. I had to go into the input manager and edit the horizontal axis to make all this possible. I had to add another public float to the PlayerController script and call it horizontalInput. I then added a horizontalInput variable called Input.GetAxis("Horizontal") I then had to multiply my turnSpeed in the transform.translate section by horizontalInput. After this I learned how to make the vehicle move forwards and backwards. To do this I had to go into my input manager and edit the vertical axis. I then had to add another public float called forwardInput. I then had to add a forwardInput variable called Input.GetAxis ("Vertical") and then multiply my turnSpeed by verticalInput. After this I was able to move my vehicle forward by pressing the forward arrow, backwards by pressing the backwards arrow and left and right by using the left and right arrow. Afterwards I learned how to make my vehicle rotate instead of slide. To do this first I had to add a new variable to my PlayerController called transform.rotate. I then had to add a new vector3 called vector3.up. I then had to delete the vector3.right line off my PlayerController and give my vehicle a turnSpeed of 25. 



Comments

  1. Well done on your tutorial. I am struggling to do mine because it won't let me progress. I will try and get it sorted anyway. I do find it quite an easy tutorial, just a few technical mistakes. You were telling me you were struggling the past week and you seem to be getting the hang of it. I'm really happy for you about that. Well done, I cannot wait to progress too.

    ReplyDelete

Post a Comment

Popular posts from this blog

Introduction Post

My Favourite Game: Grand Theft Auto Franchise

Game Alpha