For background, im doing the stealth tutorial, player movement. Ive followed the instructions, but when I came to test it, the movements are backwards. (eg W/up moves down, A/left moves right etc) Weirdly, when I sneak, the movement is the right way round.
Any ideas where I have gone wrong? If I cannot find what went wrong, should I just try to add something that inverts the keys?
Edited for clarity. So here are my issues:
My code seems to be good
My input manager settings seem to be good
My keyboard seems to be good
I face the correct direction, but I move backwards.
During Sneak, I face the correct direction and move forwards.
If I invert using the input manager I face the wrong direction and move correctly, and in sneak I face the wrong direction and move backwards.(basically doing what invert should do)
The web player seems to be working fine, and after I go through the build settings, things work well with no problems.
Both my version and the done version have this problem, but another project(roll a ball) does not.
And try to copy-paste entire code… If it won’t help - then problem is with Unity.
If that helps - then the code has fault (although I have almost the same).
You can also go to:
YourProjectDirectory/Done/DoneScenes and fire up DoneStealth.unity
If problem occurs even then… well… maybe some kind of beverage was spilled on your keyboard or cat was sitting there?
I’m also walking through the Stealth tutorials and I’m getting exactly the same issue cooledcannon started this post with.
The interesting thing is, pressing the stealth key makes the character walk forward correctly and releasing it has the character moving in reverse again. (just as cooledcannon described)
this sounds like it’s animation specific or state specific, however, when I go to the Animator tab and click on the transitions from Idle to Locomotion or from Idle to Sneak, the Preview clearly shows the character walking forward and stepping away from the origin of the Preview window.
So I was having the same problem and tried reversing the keys in ProjectSettings>Input, but the problem only became worse. Now the weirdest part is that some times when I hit play the thing runs perfectly. Also if this happens to you like it does me then toggle on the Maximize on Play button on the Game window. I’ve never had it happen when playing on fullscreen so it has to do with all those resources probably.
If you click on the “game” screen during testing, then your keys should work correctly. If you click on the “scene” screen to readjust the camera while you are testing the game, your keys will get reversed. Can anyone confirm that this is the symptom we are all having? If so, the quick solution is to click on the “game” screen while you’re testing.
I have been having the same issues, character running backwards or semi-randomly reversing direction. Changing the running speed from 5.5f to 4.5f solved the problem.
Specifically in the MovementManagement method in PlayerMovement.cs adjust the line as follows: anim.SetFloat(hash.speedFloat, 4.5f, speedDampTime, Time.deltaTime);