- Home /
how do i script wasd movement into my game
i am new to unity and trying to make a free to play game and i looked everywhere for a code to move with the wasd keys but then I import them or copy them it says that there is a error with the codes can you please help me ThankYou
Answer by UnityKen · Jan 03, 2015 at 04:36 PM
I think you should watch the unity tutorial videos, It will teach you a lot of the basics including movement. Just click on learn at the top if the page and then tutorial.
Answer by YoungDeveloper · Jan 03, 2015 at 04:17 PM
I think the unity docs are quite good in that area. http://docs.unity3d.com/ScriptReference/Input.GetKey.html
thank you very much but I am still having trouble finding out what all this means I have only coded a mod for $$anonymous$$ecraft
Please, read it carefully and try to understand. Here's a simple example.
Create a c# script, name it Test$$anonymous$$ove and copy-paste this. Place it on some gameobject in the scene and run the game.
using UnityEngine;
public class Test$$anonymous$$ove : $$anonymous$$onoBehaviour {
void Update() {
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.A))
Debug.Log("Pressing A");
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.W))
Debug.Log("Pressing W");
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.S))
Debug.Log("Pressing S");
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.D))
Debug.Log("Pressing D");
}
}
You will see a debug on the keys you are pressing.
it is regerstring it now what? becasue it is not moving thanks by the way
Here's how to move gameobject transform http://docs.unity3d.com/ScriptReference/Transform.Translate.html you are welcome by the way
Your answer
Follow this Question
Related Questions
Isometric movement 3 Answers
Laggy Movement 1 Answer
Platform Mover continued 1 Answer
whay cant i move with this script???? 3 Answers
Trouble making Dynamic Billboard 1 Answer