I’m fairly new to Unity, and in the process of learning the basic “Roll a ball”.
I followed the step until it told me to make the Player Controller script, which supposed to move the ball while pressing arrow keys / touching screen. My script did not work. The ball did not move at all in play mode no matter how much i tried to tweak it.
So i decided to download the project asset and load it from there, hoping it will work. But still nope, even though it worked just fine in the tutorial video.
I searched around and see some people said that they fixed their input problem by switching the Active Input Handling to Input Manager(Old). I tried all options there, Old, New and Both but sitll nothing worked.
Then I thought GetAxis() did not work so i tried to replace it with GetAxisRaw(). Still not working.
I checked the Input Manager, Horizontal, Vertical, .. everything seems in place there.
So next was trying to capture the key to see if it works as intended. I set a Text on screen and tried to capture all key pressed by puting a loop in Update() by this code
private void Update()
{
foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKey(kcode))
TestText.text = "KeyCode down: " + kcode;
}
}
With this, there should be a key check in everyframe and the keys I pressed are supposed to appear in the Text on screen. But nothing changed. The onscreen Text remains the value i assigned to it from Start() no matter which key I pressed. This means
all the key I pressed were not recognized by the Input system, even though all other codes run fine. The cubes that are turning around by code are turning as expected.
Please help. What else can I do ? Or what else should I provide here to show my problem ?
I’m using Unity 2022.3.27f1
Also, even though I’m in play mode, in the Scene screen, when I press arrow buttons the screen move around but not the ball. I’m pretty sure I only attached the Player Controller script to the ball though… and in the Simulator screen, nothing happened at all as described above.