Player is moving without Input

So far as I can tell, my code is the same as Section 2, Lecture 14 of the 3D Unity Course.

However, when I hit the play button the player (“Dodgy”) starts moving in the positive direction of both the X & Z axis at once, without any input by me. If I do press the arrow keys for the negative axis, it will go the other way…but I want to to work the same as it does in the lecture.

If it’s not the code, could it be a setting in Unity that has changed during updates?

Your code is fine. You probably have some ‘drift’. I think you can adjust the Dead and Sensitivity values in the Input Manager to alleviate this a bit

Thanks for the quick reply!

Unfortunately it’s still not working. I’ve even tried running it while unplugging my 3D Mouse, Keyboard and Mouse. The game runs the same every time: Any axis in the transform.Translate() causes the object to move in the negative direction specified (Sorry, I got mixed up in my original post - it’s going in the negative direction without input, not the positive).

If I increase the sensitivity and dead setting, it has no affect.

I’ve also looked online in other areas and it was suggested I use Input.GetAxisRaw(), but that doesn’t seem to make a difference either.

This is frustrating - I wish it was something simple like I messed up the script.

This is a tough one to troubleshoot. You could zip the project and I can have a look at everything inside

Apologies, certainly not trying to be a headache. I’m also playing with going back to an older version to match the Unity Version in the lecture.

Here however is a drop box for my first attempt.

Update: Quickly recreating this project from scratch in Unity 2020.1.1f1 (the version the lecture uses) fixes the problem.

That either tells me I screwed up something else somewhere that isn’t in the code, or the newer versions of Unity toggled some additional feature at some point that I didn’t know to turn on/off.

1 Like

Hi Dralle,

Did you import the scene from Unity 2020 to the newer version of Unity? If so, there might have been an internal problem in Unity.

If you recreated the scene, maybe the ground was slightly rotated in your other scene. In that case, the car would start to slide down. Or maybe there was a big collider pushing the car away.

Given you checked the values of xValue and zValue with a Debug.Log, and the values were 0f while you were not pressing the corresponding keys, the problem was not caused by your code.

I’m glad you sorted it out. I downloaded this late last night (early this morning, really) but I didn’t have the same version of Unity installed. I’ve found it is usually ok to test with a different version, so I picked the one that matches closest to the one from the project but it didn’t have the issue, so I downloaded the actual version and had problems installing it. Then I went to bed. I was going to look at this this morning but you solved it, so that’s good. Unfortunately, I can’t tell you what the problem was, but I don’t think it was the code

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms