From c0fb2077687568c615faa11767e99cb51a9bb2c7 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 12 Dec 2025 23:16:48 +0100 Subject: [PATCH] Adjust JumpPad jumpForce and PlayerController movement settings for improved gameplay dynamics --- Assets/Prefabs/Jump pad.prefab | 2 +- Assets/Prefabs/Player.prefab | 3 +- Assets/Scenes/SampleScene.unity | 10 ++--- .../Infrastructure/Unity/PlayerController.cs | 41 ++++++++++++++++--- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Assets/Prefabs/Jump pad.prefab b/Assets/Prefabs/Jump pad.prefab index 83c3f03..ff367e8 100644 --- a/Assets/Prefabs/Jump pad.prefab +++ b/Assets/Prefabs/Jump pad.prefab @@ -127,5 +127,5 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5de94b384aac49a7baa41967735126b0, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::Infrastructure.Unity.JumpPadAdapter - jumpForce: 18 + jumpForce: 20 jumpVfx: {fileID: 0} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index fc3aa02..61fe6be 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -157,8 +157,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::Infrastructure.Unity.PlayerController moveSpeed: 8 - acceleration: 50 maxVelocityChange: 10 + snapForce: 15 + useCameraRelativeMovement: 0 tileLayer: serializedVersion: 2 m_Bits: 8 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index bae6e40..967ff44 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1543,19 +1543,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalRotation.w - value: 0.89239913 + value: 0.89559084 objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalRotation.x - value: 0.23911765 + value: 0.23997289 objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalRotation.y - value: 0.3696438 + value: 0.36184213 objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalRotation.z - value: -0.09904577 + value: -0.09695532 objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1563,7 +1563,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: 45 + value: 44 objectReference: {fileID: 0} - target: {fileID: 1533471106989954094, guid: 9870f813a82bf15d5b6ac59102c82546, type: 3} propertyPath: m_LocalEulerAnglesHint.z diff --git a/Assets/Scripts/Infrastructure/Unity/PlayerController.cs b/Assets/Scripts/Infrastructure/Unity/PlayerController.cs index 940d109..3f5364f 100644 --- a/Assets/Scripts/Infrastructure/Unity/PlayerController.cs +++ b/Assets/Scripts/Infrastructure/Unity/PlayerController.cs @@ -15,6 +15,9 @@ namespace Infrastructure.Unity [SerializeField] private float maxVelocityChange = 10f; [SerializeField] private float snapForce = 15f; + [Header("Controls")] + [SerializeField] private bool useCameraRelativeMovement = true; + [Header("Interaction")] [SerializeField] private LayerMask tileLayer; [SerializeField] private float groundCheckDistance = 1.5f; @@ -23,6 +26,7 @@ namespace Infrastructure.Unity private InputSystem_Actions _actions; private Vector2 _moveInput; + private Transform _camTransform; public Rigidbody Rigidbody => rb; public StatusManager Status { get; private set; } @@ -48,6 +52,11 @@ namespace Infrastructure.Unity _actions = new InputSystem_Actions(); Status = new StatusManager(); + if (Camera.main) + { + _camTransform = Camera.main.transform; + } + rb.freezeRotation = true; rb.useGravity = true; } @@ -66,20 +75,42 @@ namespace Infrastructure.Unity private void HandleMovement() { var currentSpeed = moveSpeed * Status.CurrentCapabilities.SpeedMultiplier; - var targetVelocity = Vector3.zero; var snapAxis = Vector3.zero; - if (_moveInput.sqrMagnitude > 0.1f) + Vector3 desiredDirection; + + if (_moveInput.sqrMagnitude < 0.01f) { - if (Mathf.Abs(_moveInput.x) > Mathf.Abs(_moveInput.y)) + desiredDirection = Vector3.zero; + } + else if (useCameraRelativeMovement && _camTransform) + { + var camForward = _camTransform.forward; + var camRight = _camTransform.right; + camForward.y = 0; + camRight.y = 0; + camForward.Normalize(); + camRight.Normalize(); + + desiredDirection = (camForward * _moveInput.y + camRight * _moveInput.x).normalized; + } + else + { + desiredDirection = new Vector3(_moveInput.x, 0, _moveInput.y).normalized; + } + + + if (desiredDirection.sqrMagnitude > 0.01f) + { + if (Mathf.Abs(desiredDirection.x) > Mathf.Abs(desiredDirection.z)) { - targetVelocity = new Vector3(_moveInput.x > 0 ? currentSpeed : -currentSpeed, 0, 0); + targetVelocity = new Vector3(Mathf.Sign(desiredDirection.x) * currentSpeed, 0, 0); snapAxis = Vector3.forward; } else { - targetVelocity = new Vector3(0, 0, _moveInput.y > 0 ? currentSpeed : -currentSpeed); + targetVelocity = new Vector3(0, 0, Mathf.Sign(desiredDirection.z) * currentSpeed); snapAxis = Vector3.right; } }