Added a dev movement script
This commit is contained in:
42
Assets/Scripts/DevPlayerController.cs
Normal file
42
Assets/Scripts/DevPlayerController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DevPlayerController.cs.meta
Normal file
11
Assets/Scripts/DevPlayerController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1142ffe602591254daf84550efb544e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user