Added a dev movement script

This commit is contained in:
2026-01-15 22:10:51 +00:00
parent d4ba48e36e
commit 8584126ebe
3 changed files with 133 additions and 5 deletions

View File

@@ -0,0 +1,42 @@
using UnityEngine;
namespace InterfaceOff.WorldScene
{
public class DevPlayerController : MonoBehaviour
{
private CharacterController Controller;
public float PlayerSpeed = 5f;
public float CamSens = 2.5f;
public Transform CameraPivot;
private float MousePitch;
private void Awake()
{
Controller = GetComponent<CharacterController>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
/* Player movement */
float mouseX = Input.GetAxisRaw("Mouse X") * CamSens * 100f * Time.deltaTime;
float mouseY = Input.GetAxisRaw("Mouse Y") * CamSens * 100f * Time.deltaTime;
transform.Rotate(Vector3.up * mouseX);
MousePitch -= mouseY;
MousePitch = Mathf.Clamp(MousePitch, -85f, 85f);
CameraPivot.localRotation = Quaternion.Euler(MousePitch, 0f, 0f);
/* WASD movement */
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
Controller.Move(Time.deltaTime * PlayerSpeed * move.normalized);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1142ffe602591254daf84550efb544e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: