diff --git a/Assets/DemoGame/GameRes/Scene/Game.unity b/Assets/DemoGame/GameRes/Scene/Game.unity
index ffa13a1..05168aa 100644
--- a/Assets/DemoGame/GameRes/Scene/Game.unity
+++ b/Assets/DemoGame/GameRes/Scene/Game.unity
@@ -104,7 +104,7 @@ NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
- serializedVersion: 2
+ serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
@@ -117,7 +117,7 @@ NavMeshSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
- accuratePlacement: 0
+ buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
@@ -209,14 +209,120 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 913828149}
+ serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
- m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
+--- !u!1 &1024067690
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1024067694}
+ - component: {fileID: 1024067693}
+ - component: {fileID: 1024067692}
+ - component: {fileID: 1024067691}
+ m_Layer: 0
+ m_Name: Plane
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!64 &1024067691
+MeshCollider:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1024067690}
+ 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: 5
+ m_Convex: 0
+ m_CookingOptions: 30
+ m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!23 &1024067692
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1024067690}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_StaticShadowCaster: 0
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_RayTracingMode: 2
+ m_RayTraceProcedural: 0
+ m_RenderingLayerMask: 1
+ m_RendererPriority: 0
+ m_Materials:
+ - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_ReceiveGI: 1
+ m_PreserveUVs: 0
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 1
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+ m_AdditionalVertexStreams: {fileID: 0}
+--- !u!33 &1024067693
+MeshFilter:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1024067690}
+ m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &1024067694
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1024067690}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 5, y: 5, z: 5}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1301447167
GameObject:
m_ObjectHideFlags: 0
@@ -248,9 +354,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
+ m_Iso: 200
+ m_ShutterSpeed: 0.005
+ m_Aperture: 16
+ m_FocusDistance: 10
+ m_FocalLength: 50
+ m_BladeCount: 5
+ m_Curvature: {x: 2, y: 11}
+ m_BarrelClipping: 0.25
+ m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
- m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@@ -284,11 +398,18 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1301447167}
- m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
- m_LocalPosition: {x: 0, y: 1, z: -10}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0.30883646, y: -0, z: -0, w: 0.9511152}
+ m_LocalPosition: {x: 0, y: 11.6, z: -31.4}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
- m_RootOrder: 0
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_LocalEulerAnglesHint: {x: 35.978, y: 0, z: 0}
+--- !u!1660057539 &9223372036854775807
+SceneRoots:
+ m_ObjectHideFlags: 0
+ m_Roots:
+ - {fileID: 1301447170}
+ - {fileID: 913828151}
+ - {fileID: 1024067694}
diff --git a/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs b/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs
new file mode 100644
index 0000000..a629658
--- /dev/null
+++ b/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs
@@ -0,0 +1,169 @@
+using UnityEngine;
+
+namespace ZFramework
+{
+ ///
+ /// 用户基类
+ ///
+ [RequireComponent(typeof(CharacterController))]
+ public class PlayerBase : MonoBehaviour
+ {
+ ///
+ /// 角色控制器
+ ///
+ CharacterController characterController;
+
+ ///
+ /// 方向
+ ///
+ Vector3 direction;
+
+ ///
+ /// 移动速度
+ ///
+ [SerializeField] protected float moveSpeed = 5;
+
+ ///
+ /// 跳跃高度
+ ///
+ protected float jumpPower = 5;
+
+ ///
+ /// 重力
+ ///
+ [SerializeField] protected float gravity = 9.8f;
+
+ ///
+ /// 旋转速度
+ ///
+ protected float mouseSpeed = 5;
+
+ ///
+ /// 最小视角角度
+ ///
+ protected float minmouseY = -45;
+
+ ///
+ /// 最大视角角度
+ ///
+ protected float maxmouseY = 45;
+
+ ///
+ /// 是否能移动
+ ///
+ [SerializeField] protected bool isCanMove = true;
+
+ ///
+ /// 是否能旋转
+ ///
+ [SerializeField] protected bool isCanRotate = true;
+
+ ///
+ /// 是否能跳跃
+ ///
+ [SerializeField] protected bool isCanJump = true;
+
+ ///
+ /// 是否暂停玩家操控
+ ///
+ private bool isPause;
+
+ float RotationY = 0f;
+ float RotationX = 0f;
+
+
+ ///
+ /// 摄像机(用户视角)
+ ///
+ private Transform mainCamera;
+
+ float _horizontal;
+ float _vertical;
+
+ private void Awake()
+ {
+ OnAwake();
+ }
+
+ private void FixedUpdate()
+ {
+ if (isPause) return;
+
+ _horizontal = Input.GetAxis("Horizontal");
+ _vertical = Input.GetAxis("Vertical");
+ OnFixedUpdate();
+ }
+
+ public virtual void OnAwake()
+ {
+ isPause = false;
+ characterController = GetComponent();
+ mainCamera = transform.Find("MainCamera");
+ if (mainCamera == null) Debug.LogError("transform find not have mainCamera! please check!");
+ }
+
+ public virtual void OnFixedUpdate()
+ {
+ PlayerMove();
+ CameraRotate();
+ }
+
+ ///
+ /// 暂停玩家控制(此处的暂停包括玩家的所有控制)
+ ///
+ public virtual void Pause()
+ {
+ isPause = true;
+ }
+
+ ///
+ /// 恢复玩家控制(此处的暂停包括玩家的所有控制)
+ ///
+ public virtual void Resume()
+ {
+ isPause = false;
+ }
+
+ ///
+ /// 用户移动控制
+ ///
+ void PlayerMove()
+ {
+ if (isCanMove)
+ {
+ if (characterController.isGrounded)
+ {
+ direction = new Vector3(_horizontal, 0, _vertical);
+ if (Input.GetKeyDown(KeyCode.Space) && isCanJump)
+ direction.y = jumpPower;
+ }
+
+ direction.y -= gravity * Time.deltaTime;
+ characterController.Move(
+ characterController.transform.TransformDirection(direction * Time.deltaTime * moveSpeed));
+ }
+ }
+
+ ///
+ /// 相机旋转视角控制
+ ///
+ void CameraRotate()
+ {
+ if (isCanRotate)
+ {
+ if (Input.GetMouseButton(1))
+ {
+ RotationX += mainCamera.transform.localEulerAngles.y + Input.GetAxis("Mouse X") * mouseSpeed;
+
+ RotationY -= Input.GetAxis("Mouse Y") * mouseSpeed;
+ RotationY = Mathf.Clamp(RotationY, minmouseY, maxmouseY);
+
+ this.transform.eulerAngles = new Vector3(0, RotationX, 0);
+
+ mainCamera.transform.eulerAngles = new Vector3(RotationY, RotationX, 0);
+ }
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs.meta b/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs.meta
new file mode 100644
index 0000000..47a297a
--- /dev/null
+++ b/Assets/DemoGame/GameScript/Loader/MonoBehaviour/PlayerBase.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: cc965ce1e55644dab9aa4176ccaa6014
+timeCreated: 1731482358
\ No newline at end of file