I’m working on a top-down arpg game and here is the problem: player and enemies can collide each other. when player dashes, i’ll change the collision layer to make sure player can go through enemies. then recover the collision layer when dash ends. But player’s collision shape may overlap with a enemy after dash, then godot’s physics engine will push them away from the center point of two collision shape, that may makes them moving in a very different direction from the dash direction. it looks weird and cheap. how should i handle this in a elegant way?
What would you want it to ideally look like instead?
Because there isn’t a “one solution fits all”, this can be handled in multiple different ways, all looking different.
As @wchc said, this is a problem with many solutions, but…
If I were you, I’d turn this problem into an epic-style gamedesign opportunity!
What could happen if the player were to dash and end up within an enemy?
Do you want to reward the player for positioning themselves, so that their dash ends within an enemy. Maybe that could knock the enemy backwards, stun 'em or deal a bit of damage.
Perhaps you’d like to punish the player for not aiming their dash correctly and ending up within an enemy. (You could have similar side-effects as option 1, but now applied to the player instead.)
Maybe it should be a neutral interaction and push both the player and the enemy away from each other?
Personally, I’d reward the player, but it depends on what kind of game you are making.
And for the programming part, you could just check at the end of the dash if the player is colliding with an enemy and then applying the effects you want to apply.
(Hopefully my post is understandable. My wording skills aren’t the best)
Thanks! these solutions are great! But what i want is that if the enemy is small, the player should move in the dash direction until leave the enemy collision area. if the enemy is large, the player should blocked by the enemy because the dashing distance is too long. But that is really complex, what if there is another enemy in the landing position after player dash through the first enemy? what if the landing position is a wall? How can i predict whether the player go through a enemy or block by enemy? I mean maybe the player is just dash across the corner of a large enemy’s collision shape. My english is not good. Thank you for your answer again.