Рухи персонажу (клавіши)
// 1 - вперед, назад, вліво, вправо
public float speed = 1.0f;
Start
Cursor.lockState = CursorLockMode.Locked;
Update
float v = Input.GetAxis("Vertical") * speed;
float h = Input.GetAxis("Horizontal") * speed;
v *= Time.deltaTime;
h *= Time.deltaTime;
transform.Translate(h, 0, v);
if (Input.GetKeyDown(KeyCode.Escape)) {
Cursor.lockState = CursorLockMode.None;
}
// кросплатформенний
using UnityStandardAssets.CrossPlatformInput; // Assets->ImportPackage
CrossPlatformInputManager.GetAxis("Vertical"); // -1 або +1
// 2 - вперед, назад, обертання вліво і вправо
public float speed = 2.0f;
float v = Input.GetAxis("Vertical") * speed;
float h = Input.GetAxis("Horizontal") * speed;
transform.rotation *= Quaternion.Euler(0f, 20 * h * Time.deltaTime, 0f);
transform.position += transform.forward * v * Time.deltaTime;