using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
[SerializeField] float rotationSpeed = 0.5f;
[SerializeField] float forwardSpeed = 0.0125f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float steerAmount = Input.GetAxis("Horizontal");
float forwardAmount = Input.GetAxis("Vertical");
Debug.Log("steerAmount: " + steerAmount);
//transform.Rotate(0, 0, -steerAmount);
//transform.Translate(new Vector3(0, forwardSpeed, 0));
}
}
No matter what key I use (W, A, S, D, or arrow keys) the output is 0.
Iāve looked at the InputManager in Project Settings and aside from 30 entries in the Axis list, it all looks appropriate. I can add a screenshot if that would help, but Iām at wits end here. Iām going to have to go back to using GetKeyDown until this can be resolved.
Let me know what I can submit here to help in solving this.
There is a similar thread from someone experiencing the same issue as yours:
One thing to add here would be to check if you are even using the old input system, which you can double check in the Player Settings --> Player expand the Other Settings drop-down menu and look for Active Input Handling, but if you can use the Input.GetKey() methods than you probably are already
Also make sure that you have configured the Key or Mouse Button as the type in the Input Manager
Active Input Handling is set to āInput Manager (Old)ā
Thatās the thing, I canāt even get the Input.GetKeyDown(KeyCode.A) method to return a true condition even if I am pressing the A key.
The odd thing is that this same code is working perfectly in a different project I was working on in a different tutorial. However, in this one, I canāt seem to get any input methods to work. I have tried GetAxis, GetKeyDown, GetKey. None seem to be working in this courses project.
Looking at the quoted persons topic, I seem to be having the same problem he is, where no keyboard input is working at all. I donāt have an Event System in my Hierarchy.
I am really at a loss, since other projects I was working on are working fine with the GetKeyDown and GetKey methods. They didnāt use the GetAxis method.
I tried putting Debug.Log(Input.GetAxis(āHorizontalā)) in one of my other projects and itās working perfectly!
I started Delivery Driver in 2021.3.37f1(LTS) and have changed it to 2022.3.24f1(LTS) thinking that the older version may have been the issue. As far as I can tell, its not. I am currently in 2022.3.24f1(LTS) in both projects now. One works as expected and the Delivery Driver project is not.
If you donāt mind, do share a screenshot of your Input Manager with us. Just expand the first horizontal dropdown menu & do as well compare your configuration with the other projects yourself if it works there.
As this is a small project for the time being (I guess), consider migrating your current project to a new one, otherwise we would need to take a deeper look
Funny thing I have created a new project, added a Sprite2D, created a script and added it to the sprite2D object, in the Update method added the Debug.Log(Input.GetAxis(āHorizontalā)) and I still get 0ās.
I compared the two project settings from the working input system and non-working input system. They look the same, but there are a lot of settings I didnāt open. I just opened the Horizontal.
I have a 3D project I have been working on following āCode Monkeyāsā tutorial Kitchen Chaos. GetAxis works fine in that project too.
Iām just going to take this opportunity to uninstall Unity and reinstall it on an SSD drive. Iām not a complete newb when it comes to programming. Just to Unity. Iām learning, but this problem has me totally stumped.
Iāll let you know if reinstalling has a positive result.
Can you zip up the project, upload it somewhere and share it? I can look at it and if itās a Unity problem, I would get the same behaviour, but if itās hardware or something, then it would work for me as expected. I could also see if I can solve it, should I also get the same behaviour
I downloaded your project but didnāt have the same Unity version (2022.3.26f1) so I opened it in 2022.3.5f1 instead. All worked as expected.
Downloaded 2022.3.26f1 and opened it there. All worked as expected.
Deleted the project and unzipped it again (suspected the 2022.3.5f1 ādowngradeā changed some things) and this time opened it in 2022.3.26f1. Broken
Closed Unity, deleted the āLibrary Folderā and opened it again. Broken.
Then I saw itā¦
The game window is not focused. Clicking on it would give it focus and then controls will work. Changing that to āPlay Focusedā or āPlay Maximisedā will also forward focus to the game window and then it should be fine.
Oh my goodness guys! Thank you SO, SO, SO much! I did change that setting in other projects, I just didnāt realize that it had that kind of effect on the input manager!
I really thought I had broke something or made a change to a setting deep inside something that wasnāt going to be seen!
Obviously, Iām never going to forget this again! I guess that setting is for testing a program when the game window looses focus.