Hello all!
I’m having an issue with what’s described in the title. When my player hits spacebar, the player’s movement speed will momentarily be increased and a “isDashing” boolean will be set to true, both effects being disabled once the dash is over.
During the dash, I want my player to:
- Be able to go through enemies (enemies have colliders so they normally block movement)
- Do NOT go through the borders of the map (the map is covered with edge colliders to mark the boundaries).
- If the player is dashing along the walls of the map, they should kinda slide against the walls, not stop completely (i.e. imagine if you run diagonally into a wall, you’re gonna slide against the wall).
Here’s what I’ve tried and the issues I ran into with each:
- I tried simply disabling the player colliders while dashing. This accomplishes the goals of phasing through enemies but the player ALSO phases through the walls.
- I tried disabling the enemy colliders if they detect that they’ve collided with the player while isDashing is true. However, If the enemy is standing against a wall while the player dashes through them, they can clip through the walls.
Here are some things that I currently see as non-viable solutions (but maybe I’m wrong):
- I can’t have huge, thick as my map borders because the edge of my map is quite complex/squiggly.
- I can’t just set moveSpeed to 0 while contacting the wall because that would mean even if my player is just barely contacting the wall while dashing against it, they’d stop in their tracks as opposed to sliding against it.
- I can’t really deal with this kinematically since I’m not sure how I’d replicate sliding against the wall with kinematic rigidbodies as opposed to dynamic.
I basically need to find a way to make it so while the player is dashing, they stop colliding with the enemy collider but they collide normally with everything else.
Any ideas would be greatly appreciated. Thank you for your time!