Unity Beginner Tutorial - Part 1b(Keyboard input object Control)

Опубликовано: 28 Сентябрь 2024
на канале: Md Sakiluzzaman
87
3

Code Used in this Video:

using UnityEngine;
using System.Collections;

public class Move : MonoBehaviour {

public float speed;
void Start () {

}


void Update () {
if (Input.GetKey (KeyCode.D)) {
transform.position += new Vector3 (speed, 0, 0);
}

if (Input.GetKey (KeyCode.A)) {
transform.position += new Vector3 (-speed, 0, 0);
}

if (Input.GetKey (KeyCode.W)) {
transform.position += new Vector3 (0, 0, speed);
}

if (Input.GetKey (KeyCode.S)) {
transform.position += new Vector3 (0, 0, -speed);
}

}
}