Search Unity

I can't make my vehicle turn in Unity Junior Programmer Lesson 1.4

Discussion in 'Community Learning & Teaching' started by taylorhubbard, Dec 10, 2021.

  1. taylorhubbard

    taylorhubbard

    Joined:
    Oct 10, 2021
    Posts:
    3
    So, I have been working through the Unity courses, and I am currently on Junior Programmer. However, I have run into a debilitating issue that has brought my progress to a halt. Currently, I am on lesson 1.4, and I can't seem to get the tank to turn. The horizontal input meter moves in the inspector, but nothing happens to the turn speed. What am I doing wrong?
    Here is my code for the PlayerController.cs file:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.     public float speed = 5f;
    8.     public float turnSpeed;
    9.     public float horizontalInput;
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.        
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.         horizontalInput = Input.GetAxis("Horizontal");
    20.         //Move the vehicle forward
    21.         transform.Translate(Vector3. forward * Time.deltaTime * speed);
    22.         transform.Translate(Vector3.right * Time.deltaTime * turnSpeed * horizontalInput);
    23.     }
    24. }
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    Did you set the Turn Speed in the Inspector to 1? (Time in video 00:05:05 - 00:05:08)
     
    supriob9 likes this.
  3. richardjeroense

    richardjeroense

    Joined:
    May 18, 2017
    Posts:
    2
    Hi Taylor, i have the same issue om my Mac using Unity 2020.03.24f1. The code is correct, but the vehicle does not move with my keyboard letters and arrows. Not sure if I should update to the new Input Manager package instead, but that is not covered in the Junior Programmer course yet. Anyone any other ideas?
     
  4. richardjeroense

    richardjeroense

    Joined:
    May 18, 2017
    Posts:
    2
    Hi Taylor, I managed to solve it. My Unity layout displays both the Scene as well as the Game window in one screen. Even though I was clicking the Play button, the arrow keys did not seem to work. I also had to click in the actual Game window with my mouse, and then the arrow keys did show effect. Please try, maybe this solves your issue too.