Movement not working

Hi,

I think I’ve followed all of the steps correctly, but I can’t move the Player at all.
I’m on Mac.
I hope someone knows how to help me. Thanks in advance!

Did you attach the script onto the player as a component

Yep!

Hi Mapplec,

What’s the moveSpeed value in your Inspector? And could you please share a screenshot of the Inspector of the game object you’d like to move?

My moveSpeed is 10f in the inspector

Your code and your Inspector look fine. Did you press the Play button in Unity? If so, check the console. Are there any error messages when the player is supposed to move?

I pressed the Play button in Unity. The console hasn’t got any messages written inside of it.
Really strange… thanks for taking the time to respond! ^^

Create a new game object and assign the Mover script to it. No need for any other components such as a collider. Then test your script with that game object.

hmmm… Still nothing. Every time I create a new object it gets a collider automatically.

What happens if you increase the moveSpeed value in your Inspector. Set it, for example, to 100f.

And log xValue and zValue into your console to see what values you are getting during runtime while pressing the keys. If the values remain 0f, log Time.deltaTime and the GetAxis values separately into your console.

I think I did what you said? :face_with_monocle: this is the result. The Time.deltaTime is fluctuating, the rest is giving me a 0f



Good job so far. :slight_smile:

Now we know that the problem is very likely caused by GetAxis, not necessarily by your code or your scene. This is good to know because we won’t have to stare at the code anymore or look for problems in the scene.

Which keys did you press to move your player? If you used the WASD keys, go to Edit > Project Settings > Input Manager and look for “Horizontal” and “Vertical”. Then expand them if they are not already expanded and share a screenshot. Maybe they are not referencing the expected keys.

For future reference, please always add a meaningful message to your Debug.Logs because that’ll make it easier to interpret the output in the console.

Thanks! I’m very glad you’re helping me! :slight_smile:
Here are the project settings screenshots:


As for, not having to stare at the code anymore. :joy: I think this is ok for the meaningful messages?

Your screenshots look fine, too. And yes, those are meaningful messages. If you log the value of xValue into your console, and the console says something like “xValue: 0”, that’s a clear message with does not leave much room for interpretation. :slight_smile:

Which keys on your keyboard did you press to move your player? Test the left and the right arrows but not the ones on your numpad. Also test the WASD keys. You could also plug your keyboard out and in again.

If nothing helps, I’d suggest to install the latest version of Unity.

Make a backup of your project folder by duplicating it. Save the duplicated folder somewhere else, maybe on an USB stick. To save some free space, you could delete the Library and Temp folders in the backup folder.

Then import your current project (not the backup!) into the new version of Unity. Maybe you are just experiencing a bug in this version.

Alrighty, I’ll try all those things and will let you know how it works out.
Thanks for all the help!!

Ok… bit weird. I created a new project and and re-wrote the code. Everything works as it should now…
Really can’t think of what I did differently in the other project… Anyhow, I can finally go on with the course!! :smiley: :smiley: :smiley: Thankssss!!!

So, now. The next lecture I’m following, I’m adding a CineMachine Virtual Camera and my movement stopped working altogether again. :cry: I think I"m going to install another version of unity like you said…

If the movement stops working again in the new version, close Unity and Visual Studio Code. Then go to your project folder and delete the Library folder in it. If there is a Temp folder, delete it as well. Then start Unity again. As it seems, a few students had issues with the Unity cache in the past few months. I assume that something was changed in Unity (by Unity, not by the students) which causes these problems.

Make sure your project folder is on your normal harddrive, not in some cloud or elsewhere on the internet, an USB-stick or whatever. Starting Unity with administrator rights (right click on Unity/Unity Hub to find that option on Windows) might also help.

Regarding the cinemachine, make sure everything is done exactly as in Rick’s case. And if the issue persists, report a bug to Unity via Help > Report a bug.

Has this issue been resolved? I have the same problem on a Mac and worked through all the suggested fixes. I tried both 2020.3.19f1 and 2021.1.23f1

Seems to be a problem with GetAxis. I gotta say it’s really frustrating to hit this roadblock in the first project of the course with only 4 lines of code. I’ve done several more complicated tutorials of complete games from YouTube that all worked fine.

Just a thought…
Is the New Input System active? Instead of the old one?

Privacy & Terms