PlayerController Built-in Dash
π‘
6
π
2
π―
2
π₯
2
This add-on updates the dash ability by integrating it directly into the PlayerController code, allowing players to dash without needing to equip a specific ability!
PlayerController.cs (line 17 to 21):
[Header("Dash")]
[SerializeField][Min(0)] private float m_dashStrength = 1;
[SerializeField][Min(0)] private float m_dashResistance = 1;
[SerializeField] private ParticleSystem m_dashParticleSystem = null;
PlayerController.cs (line 50):
GameManager.InputSystem.gameplay.dash.performed += OnDash;
PlayerController.cs (line 62):
GameManager.InputSystem.gameplay.dash.performed -= OnDash;
PlayerController.cs (line 143 to 156):
private void OnDash(InputAction.CallbackContext context)
{
Vector2 direction =
m_character.IsMoving() ?
m_character.movementDirection :
(m_character.GetLookAtDirection() == EDirection.Right ? Vector2.right : Vector2.left);
m_character.Push(direction, m_dashStrength, m_dashResistance, faceOppositeDirection: true);
if (m_dashParticleSystem != null)
{
m_dashParticleSystem.Play();
}
}
// Line break so it looks nicer :)
InputSystem.cs (line 10):
public InputAction dash;
InputSystem.cs (line 81):
dash = actions.FindAction("Dash"),
Usage:
- Open
Dash.prefab - Copy the
Particle Systemcomponent - Open
0_Hero_Base.prefab - Create a child Game Object to the base
- Paste the
Particle Systemcomponent in this new Game Object - Select the root (
0_Hero_Base) - Scroll down to
Player Controller, and set the dash strength and resistance (18 and 12 work well for me) - Set the
Dash Particle Systemreference by drag-and-dropping the Game Object you just created in the field - Open
PlayerInputActions.inputactions - Duplicate the “Interact” action in the Gameplay map
- Rename it to “Dash”
- Update its bound keys (Keyboard & Gamepad)
- Save the asset
PlayerController Built-in Dash

π¬ Comments (15)
PlayerControllerscript i keep getting those 2 errors, even tho i’ve doubled checked and nothing seems to be wrong, if needed i can share my code and maybe you can see if i actually did a mistake or notNo the semicolon is actually there tho (on the line it says where the error is) π€
Want me to send the code over, or? I could be wrong obviously but i believe it’s there
Doesn’t seem to be that, this is how the lines look
and even if i give line 81 a semicolon instead of “,” i get more erros (shown on the third pic)
dash = actions.FindAction("Dash"),inside of thePlayerController.csclass. If you follow the instruction, this line should be added toInputSystem.cs(line 81)0_Hero_Base.prefabWant to continue the conversation?