Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Junior Programmer Course - Issues with "Unit 1 - Player Control": Input.GetAxis not working

Discussion in 'Community Learning & Teaching' started by AdamJamesUnity, Jun 28, 2022.

  1. AdamJamesUnity

    AdamJamesUnity

    Joined:
    May 31, 2022
    Posts:
    1
    Hi there,

    I'm new to this forum and unsure if this is the right place to post this. Please let me know if there is somewhere more appropriate.

    I currently working thought the Junior Programming course and I'm stuck on "Unit 1 - Player Control" and in particular "Lesson 1.4 - Step into the Driver's Seat". The "horizontalInput" variable does not seem to be working even tho I have copied the course instructions (See below).

    Am I missing something or is this possible an outdated lesson with the latest version of Unity?

    Thanks in advance to anyone who replies!

    Adam


    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 = 5.0f;
    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.  
    21.         transform.Translate(Vector3.forward * Time.deltaTime * speed);
    22.         transform.Translate(Vector3.right * Time.deltaTime * turnSpeed * horizontalInput);
    23.        
    24.     }
    25. }
    26.  
     
  2. GneissicGames

    GneissicGames

    Joined:
    Aug 20, 2022
    Posts:
    1
    I am having the same issue and can't find any solutions :(
     
  3. brokehampton

    brokehampton

    Joined:
    Dec 9, 2020
    Posts:
    2
    Same here.. I can see the numbers in the Horizontal Input field in the inspector changing, so the code is definitely right. The object itself just isn't moving.
     
  4. brokehampton

    brokehampton

    Joined:
    Dec 9, 2020
    Posts:
    2
    Set the turn speed to something other than 0.
     

    Attached Files: