Скрипт движения игрока по клавишам WSAD:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float speed = 5f; public float rotate = 180f; // Start is called before the first frame update void Start() { Debug.Log("Привет, Мир"); } // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.W)) { transform.Translate(new Vector3(0, 0, speed * Time.deltaTime)); } if (Input.GetKey(KeyCode.S)) { transform.Translate(new Vector3(0, 0, - speed * Time.deltaTime)); } if (Input.GetKey(KeyCode.A)) { transform.Rotate(new Vector3(0, - rotate * Time.deltaTime, 0)); } if (Input.GetKey(KeyCode.D)) { transform.Rotate(new Vector3(0, rotate * Time.deltaTime, 0)); } } }
Добавить комментарий