|
|
@ -4,6 +4,7 @@ using UnityEngine.Events; |
|
|
|
public class CharacterController2D : MonoBehaviour |
|
|
|
{ |
|
|
|
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
|
|
|
|
[SerializeField] private float m_WallJumpMultiplier = 3f; // Amount of force added when the player jumps off a wall.
|
|
|
|
[Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100%
|
|
|
|
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
|
|
|
|
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
|
|
|
@ -87,7 +88,6 @@ public class CharacterController2D : MonoBehaviour |
|
|
|
if (!crouch) |
|
|
|
{ |
|
|
|
// If the character has a ceiling preventing them from standing up, keep them crouching
|
|
|
|
if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround)) |
|
|
|
{ |
|
|
|
crouch = true; |
|
|
|
} |
|
|
@ -158,13 +158,13 @@ public class CharacterController2D : MonoBehaviour |
|
|
|
{ |
|
|
|
if (m_FacingRight && m_LastWallJumpDirection == Direction.L) |
|
|
|
{ |
|
|
|
m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); |
|
|
|
m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); |
|
|
|
|
|
|
|
m_LastWallJumpDirection = Direction.R; |
|
|
|
} |
|
|
|
else if (!m_FacingRight && m_LastWallJumpDirection == Direction.R) |
|
|
|
{ |
|
|
|
m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); |
|
|
|
m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); |
|
|
|
|
|
|
|
m_LastWallJumpDirection = Direction.L; |
|
|
|
} |
|
|
|