From 2ac3ab0c6a315e678d21aa6bd4a0a660a2c46acf Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 18 Feb 2022 15:15:07 +0800 Subject: *misc --- .../Demo/Scenes/FPSCharacterController.unity | 1 + JamHelper/Assets/JamUtils/FPSControllerVelocity/README~ | 1 + .../FPSControllerVelocity/Scripts/FPSCharacterController.cs | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 JamHelper/Assets/JamUtils/FPSControllerVelocity/README~ (limited to 'JamHelper/Assets/JamUtils/FPSControllerVelocity') diff --git a/JamHelper/Assets/JamUtils/FPSControllerVelocity/Demo/Scenes/FPSCharacterController.unity b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Demo/Scenes/FPSCharacterController.unity index 139d3fa..c8da4c6 100644 --- a/JamHelper/Assets/JamUtils/FPSControllerVelocity/Demo/Scenes/FPSCharacterController.unity +++ b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Demo/Scenes/FPSCharacterController.unity @@ -924,6 +924,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 60e373202cc879c4a8e781f92dbdcb48, type: 3} m_Name: m_EditorClassIdentifier: + type: 5 --- !u!114 &148244783 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/JamHelper/Assets/JamUtils/FPSControllerVelocity/README~ b/JamHelper/Assets/JamUtils/FPSControllerVelocity/README~ new file mode 100644 index 0000000..c240298 --- /dev/null +++ b/JamHelper/Assets/JamUtils/FPSControllerVelocity/README~ @@ -0,0 +1 @@ +用rigidbody.velocity移动角色 \ No newline at end of file diff --git a/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/FPSCharacterController.cs b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/FPSCharacterController.cs index a6d844f..3884a26 100644 --- a/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/FPSCharacterController.cs +++ b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/FPSCharacterController.cs @@ -155,7 +155,7 @@ namespace JamTools Vector3 right = transform.right; Vector3 forward = transform.forward; - m_MoveDirection = right * moveX + forward * moveZ; + Vector3 dir = right * moveX + forward * moveZ; if (IsModuleActive(CharacterModule.WalkOnSlope)) { @@ -165,17 +165,18 @@ namespace JamTools if (Physics.Raycast(m_GroundChecker.foot.position, Vector3.down, out hitInfo)) { Vector3 normal = hitInfo.normal; - m_MoveDirection = Vector3.ProjectOnPlane(m_MoveDirection, normal); + dir = Vector3.ProjectOnPlane(dir, normal); GizmosHandle.Instance.DoGizmos(() => { - Gizmos.DrawLine(hitInfo.point + new Vector3(0, 0.1f, 0), hitInfo.point + m_MoveDirection); + Gizmos.DrawLine(hitInfo.point + new Vector3(0, 0.1f, 0), hitInfo.point + dir); }); } } } - m_MoveDirection = m_MoveDirection.normalized; + dir = dir.normalized; + m_MoveDirection = Vector3.Slerp(m_MoveDirection, dir, 1f); } void MoveAroundFixedUpdate() @@ -370,6 +371,7 @@ namespace JamTools private void Update() { + LookAround(); MoveAroundUpdate(); MoveInAirUpdate(); Jump(); @@ -383,7 +385,6 @@ namespace JamTools private void FixedUpdate() { - LookAround(); MoveAroundFixedUpdate(); MoveInAirFixedUpdate(); DodgeFixed(); -- cgit v1.1-26-g67d0