Super Silly Simple Unity FPS WASD player movement script

In case you need a simple script to move your game character using WASD buttons, feel free to use it:

float speed = 1f;
float rspeed = 5f;

if (Input.GetKey(KeyCode.A)){
	transform.Translate(-speed * Time.deltaTime, 0f, 0f);
if (Input.GetKey(KeyCode.D)){
	transform.Translate(speed * Time.deltaTime, 0f, 0f);

if (Input.GetKey(KeyCode.W)){
	transform.Translate(0f, 0f, speed * Time.deltaTime);

if (Input.GetKey(KeyCode.S)){
	transform.Translate(0f, 0f, -speed * Time.deltaTime);

if (Input.GetKey(KeyCode.Q)){
	transform.Rotate(0f, -rspeed * Time.deltaTime, 0f);

if (Input.GetKey(KeyCode.E)){
	transform.Rotate(0f, rspeed * Time.deltaTime, 0f);

Leave a Reply

Your email address will not be published. Required fields are marked *