Browse Source

Wall jump feeeling nice

jeff
Jeff 2 years ago
parent
commit
6dbb8bfaab
2 changed files with 5 additions and 5 deletions
  1. BIN
      Assets/Scenes/WalljumpTest.unity
  2. +3
    -3
      Assets/Scripts/Character/CharacterController2D.cs

BIN
Assets/Scenes/WalljumpTest.unity (Stored with Git LFS) View File

size 276836

+ 3
- 3
Assets/Scripts/Character/CharacterController2D.cs View File

@ -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;
}

Loading…
Cancel
Save