Enemy collision

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaxTuz

Hi
My opponent only moves along the x-axis, that is, left and right, and bounces off the wall. I have such a problem, when a player collides with him, the player dies and is reborn, and the enemy continues to move, but from the fact that the player collides with him, he moves to another point of movement, that is, the opposite side of the collision bounces off the player, thereby colliding with other objects. How to fix it.

:bust_in_silhouette: Reply From: ejricketts

I take it you want the enemy to keep patrolling even if it collides with the player?

Sounds to me like you have it set up so that your enemy is detecting collisions, and if it detects one then its direction changes, as to bounce off the wall.
In this case, you need to look at using layers and masks so that it will only detect collisions with those of the wall and not the player.