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

@@ -271,6 +271,81 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &933837795
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 933837798}
- component: {fileID: 933837797}
- component: {fileID: 933837796}
m_Layer: 0
m_Name: DevPlayer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!143 &933837796
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 933837795}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Height: 1.5
m_Radius: 0.4
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &933837797
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 933837795}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1142ffe602591254daf84550efb544e1, type: 3}
m_Name:
m_EditorClassIdentifier:
PlayerSpeed: 3.5
CamSens: 3
CameraPivot: {fileID: 1193332431}
--- !u!4 &933837798
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 933837795}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: -6, y: 0.75, z: -20}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1193332431}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!1 &988211805 --- !u!1 &988211805
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -519,12 +594,12 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1193332428} m_GameObject: {fileID: 1193332428}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3.083, y: 1, z: -0.496} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 933837798}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1193332432 --- !u!114 &1193332432
MonoBehaviour: MonoBehaviour:
@@ -577,7 +652,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1193332428} m_GameObject: {fileID: 1193332428}
m_Enabled: 1 m_Enabled: 0
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 42603e4f95b24efa85355a04450c20e2, type: 3} m_Script: {fileID: 11500000, guid: 42603e4f95b24efa85355a04450c20e2, type: 3}
m_Name: m_Name:
@@ -728,7 +803,6 @@ PrefabInstance:
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_Roots: m_Roots:
- {fileID: 1193332431}
- {fileID: 798257144} - {fileID: 798257144}
- {fileID: 8020063586600593708} - {fileID: 8020063586600593708}
- {fileID: 2041731858} - {fileID: 2041731858}
@@ -737,3 +811,4 @@ SceneRoots:
- {fileID: 832169854} - {fileID: 832169854}
- {fileID: 988211806} - {fileID: 988211806}
- {fileID: 1176743697} - {fileID: 1176743697}
- {fileID: 933837798}

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: