Feat: Dash
Implemented basic dash logic WITHOUT cooldowns. Needs more changes down the line
This commit is contained in:
@@ -11,11 +11,14 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
private CharacterController controller;
|
||||
private Vector3 velocity;
|
||||
private Vector3 move;
|
||||
private PlayerSkillTree PlayerSkills;
|
||||
private PlayerSkillHandler playerSkillHandler;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerSkills = PlayerSkillTree.Instance;
|
||||
playerSkillHandler = new PlayerSkillHandler();
|
||||
}
|
||||
|
||||
void Start()
|
||||
@@ -27,7 +30,13 @@ public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
HandleDash();
|
||||
/* Ugly part here, need to rewrite later */
|
||||
float moveX = Input.GetAxisRaw("Horizontal");
|
||||
float moveZ = Input.GetAxisRaw("Vertical");
|
||||
/* End of the ugly part :P */
|
||||
|
||||
move = new Vector3(moveX, 0, moveZ).normalized;
|
||||
StartCoroutine(playerSkillHandler.DashCoroutine(controller, move));
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.L))
|
||||
@@ -45,6 +54,15 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (playerSkillHandler.IsDashing())
|
||||
{
|
||||
Physics.IgnoreLayerCollision(6, 7, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Physics.IgnoreLayerCollision(6, 7, false);
|
||||
}
|
||||
|
||||
HandleMovement();
|
||||
ApplyGravity();
|
||||
}
|
||||
@@ -53,7 +71,7 @@ public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
float moveX = Input.GetAxisRaw("Horizontal");
|
||||
float moveZ = Input.GetAxisRaw("Vertical");
|
||||
Vector3 move = new Vector3(moveX, 0, moveZ).normalized;
|
||||
move = new Vector3(moveX, 0, moveZ).normalized;
|
||||
|
||||
if (move.magnitude >= 0.1f)
|
||||
{
|
||||
@@ -66,19 +84,6 @@ public class PlayerMovement : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDash()
|
||||
{
|
||||
if (PlayerSkills.IsSkillUnlocked(PlayerSkillTree.Skills.Dash))
|
||||
{
|
||||
// Implement dash logic
|
||||
Debug.Log("Dashing!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Dash skill is not unlocked.");
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyGravity()
|
||||
{
|
||||
if (IsGrounded() && velocity.y < 0) velocity.y = -2f;
|
||||
|
||||
Reference in New Issue
Block a user