PlayerController.cs (Génération Procédurale - Épisode 13)
Script utilisé dans l'épisode 13 de la série génération procédurale (Basé sur le repo suivant : https://github.com/jiankaiwang/FirstPersonController)
Copier
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 10.0f;
private float translation;
private float straffe;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
translation = Input.GetAxis("Vertical") * speed * Time.deltaTime;
straffe = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
transform.Translate(straffe, 0, translation);
if (Input.GetKeyDown("escape"))
{
Cursor.lockState = CursorLockMode.None;
}
}
}