i guess my code is correct but then the object isnt moving on unity , can someone help
Hi Fadil,
First of all, check if the Mover script is assigned to the game object you’d like to move. The component in the Inspector must not be disabled.
Secondly, if the Move component is attached to the player, use Debug.Log to see what values Input.GetAxis when you press the WASD keys. Maybe they return 0f all the time even if you keep pressing the correct keys down. In that case, the problem would not be in your code but probably in Unity’s settings.
I hope this helped.
See also:
- Forum User Guides : How to apply code formatting within your post
- Forum User Guides : How to mark a topic as solved
sorry i didnt get you
For example like this to check the “horizontal” keys (A, D, left arrow, right arrow):
Debug.Log("Horizontal: " + Input.GetAxis("Horizontal"));
Hello, I do not know if you are creating 2D or 3D game,
but in a 2D you should have transform.Translate(xvalue,yvalue,o); because Y is up and down Z is to and from camera.
another thing here, I am missing some float like moveSpeed that also multiplies that xValue and zValue.