From 26e6d66851086a16f20c279375cd73d99127734a Mon Sep 17 00:00:00 2001 From: MuhamadAjiW <16521119@mahasiswa.itb.ac.id> Date: Wed, 17 Apr 2024 17:40:19 +0700 Subject: [PATCH] fix: walking, comments --- Assets/Scripts/Config/CameraConfig.cs | 2 ++ Assets/Scripts/Config/GameConfig.cs | 4 ++-- Assets/Scripts/Core/Game/GameCameraController.cs | 3 +++ Assets/Scripts/Core/Player/PlayerAnimationController.cs | 3 +-- Assets/Scripts/Core/Player/PlayerMovementController.cs | 3 +++ Assets/Scripts/Core/Player/PlayerStateController.cs | 1 + Assets/Scripts/Core/Player/PlayerStats.cs | 2 +- Assets/Scripts/Library/BaseClasses/RigidObject.cs | 1 + 8 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Config/CameraConfig.cs b/Assets/Scripts/Config/CameraConfig.cs index 1f73fd45..151a6d51 100644 --- a/Assets/Scripts/Config/CameraConfig.cs +++ b/Assets/Scripts/Config/CameraConfig.cs @@ -2,6 +2,8 @@ using UnityEngine; public static class CameraConfig{ + // Movement lerp constants public static float DEFAULT_FOLLOWING_SPEED = 0.1f; + // Offset for follow camera public static Vector3 DEFAULT_CAMERA_OFFSET = new(0f, 0.2f, -2f); } \ No newline at end of file diff --git a/Assets/Scripts/Config/GameConfig.cs b/Assets/Scripts/Config/GameConfig.cs index 90cfb63f..c99d8100 100644 --- a/Assets/Scripts/Config/GameConfig.cs +++ b/Assets/Scripts/Config/GameConfig.cs @@ -1,5 +1,5 @@ public static class GameConfig{ - // Config - public static float MOVEMENT_SMOOTHING = 0.2f; + // Movement lerp constants + public static float MOVEMENT_SMOOTHING = 0.14f; public static float ROTATION_SMOOTHING = 720; } \ No newline at end of file diff --git a/Assets/Scripts/Core/Game/GameCameraController.cs b/Assets/Scripts/Core/Game/GameCameraController.cs index 486b9862..147cb6cf 100644 --- a/Assets/Scripts/Core/Game/GameCameraController.cs +++ b/Assets/Scripts/Core/Game/GameCameraController.cs @@ -3,15 +3,18 @@ using Unity.VisualScripting; using UnityEngine; public class GameCameraController { + // Attributes private Camera activeCamera; private CameraBehaviour behaviour; private CameraBehaviourType behaviourType; + // Constructor public GameCameraController(Camera camera){ activeCamera = camera; activeCamera.enabled = true; } + // Functions public void SwapCamera(Camera camera){ activeCamera.enabled = false; activeCamera = camera; diff --git a/Assets/Scripts/Core/Player/PlayerAnimationController.cs b/Assets/Scripts/Core/Player/PlayerAnimationController.cs index b59864af..a8abdec0 100644 --- a/Assets/Scripts/Core/Player/PlayerAnimationController.cs +++ b/Assets/Scripts/Core/Player/PlayerAnimationController.cs @@ -20,9 +20,8 @@ public class PlayerAnimationController{ player.stateController.OnStateChange += Animate; } + // Functions public void Animate(){ - Debug.Log("State changed " + player.stateController.state); - switch (player.stateController.state){ case PlayerState.IDLE: animator.SetBool(IDLE_TRIGGER, true); diff --git a/Assets/Scripts/Core/Player/PlayerMovementController.cs b/Assets/Scripts/Core/Player/PlayerMovementController.cs index 050a897e..3e31d626 100644 --- a/Assets/Scripts/Core/Player/PlayerMovementController.cs +++ b/Assets/Scripts/Core/Player/PlayerMovementController.cs @@ -2,12 +2,15 @@ using Unity.VisualScripting; using UnityEngine; public class PlayerMovementController{ + // Attributes private Player player; + // Constructor public PlayerMovementController(Player player){ this.player = player; } + // Functions private void HandleRotation(Vector3 moveDirection){ Quaternion target = Quaternion.LookRotation(moveDirection, Vector3.up); diff --git a/Assets/Scripts/Core/Player/PlayerStateController.cs b/Assets/Scripts/Core/Player/PlayerStateController.cs index fddc865c..43aa2cae 100644 --- a/Assets/Scripts/Core/Player/PlayerStateController.cs +++ b/Assets/Scripts/Core/Player/PlayerStateController.cs @@ -9,6 +9,7 @@ public class PlayerStateController : StateController{ this.player = player; } + // Functions private bool DetectJumping(){ return !player.Grounded && player.Rigidbody.velocity.y > 0; } diff --git a/Assets/Scripts/Core/Player/PlayerStats.cs b/Assets/Scripts/Core/Player/PlayerStats.cs index e53edcca..b66b8484 100644 --- a/Assets/Scripts/Core/Player/PlayerStats.cs +++ b/Assets/Scripts/Core/Player/PlayerStats.cs @@ -2,7 +2,7 @@ public class PlayerStats { // Attributes private Player player; public float walkSpeed = 10; - public float sprintSpeed = 25; + public float sprintSpeed = 20; public float jumpForce = 600; public float snapshotSpeed = 25; diff --git a/Assets/Scripts/Library/BaseClasses/RigidObject.cs b/Assets/Scripts/Library/BaseClasses/RigidObject.cs index 4964e29a..c7d67791 100644 --- a/Assets/Scripts/Library/BaseClasses/RigidObject.cs +++ b/Assets/Scripts/Library/BaseClasses/RigidObject.cs @@ -22,6 +22,7 @@ public class RigidObject : MonoBehaviour { collider = GetComponent<Collider>(); } + // Functions protected void Refresh(){ Rigidbody.AddForce(Vector2.zero); } -- GitLab