0

Movement coding

I need help.......?I am trying to make game from unity but I do my code and nothing happens if someone could give me a working movement with the keys being wasd. I would really appreciate I. thank you

7th Apr 2018, 9:23 PM
Rusty Self
Rusty Self - avatar
6 Réponses
+ 1
Use Debug.log() to write info about the variables. It will be good debugging practice
7th Apr 2018, 9:52 PM
Ariela
Ariela - avatar
0
Can you post the code?
7th Apr 2018, 9:38 PM
Ariela
Ariela - avatar
0
This is an official unity tutorial. They can be very useful https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/moving-player
7th Apr 2018, 9:40 PM
Ariela
Ariela - avatar
0
But the gist is (you may need to change the Y and Z coords depending on how the game is set up.) change the speed until it feels right float speed = 5.0f; void Update(){ newX =player.position.x; newY =player.position.y; if(Input.GetKey(KeyCode.W)){ newX += speed * Time.deltaTime; } if(Input.GetKey(KeyCode.S)){ newX -= speed * Time.deltaTime; } if(Input.GetKey(KeyCode.A)){ newY += speed * Time.deltaTime; } if(Input.GetKey(KeyCode.D)){ newY -= speed * Time.deltaTime; } player.position = new Vector3(newX,newY,player.position.y) }
7th Apr 2018, 9:44 PM
Ariela
Ariela - avatar
0
thank u guys I don't have code on my mobile but no errorson the console but when I hit play my person doesn't move
7th Apr 2018, 9:46 PM
Rusty Self
Rusty Self - avatar
0
oh okay BC I have tried and tried to rewright my code but every time its the same thing!!!!!so use debug.log()
7th Apr 2018, 9:55 PM
Rusty Self
Rusty Self - avatar