How do I keep enemies (rigidbodies) from pushing each other?
Hello, I am making a 2D tower defense game, where enemies come toward the player in waves. Once the enemies reach a certain distance from the player, they stop and attack. However, when there are multiple enemies, they all try to reach the stop distance to the player, so they push each other. I tried fixing this problem by making the enemies have their own stop distance, so the enemies behind them would stop if the distance was too close, but that idea quickly failed, as I realized that the enemy in front would stop as well. Is there a way to make enemies stop ONLY if they are behind another enemy? Thank you much! (P.S. forgive my username. I created this account a while ago.)
Answer by LordDAVidus · Nov 13, 2020 at 11:18 AM
As I understand your question, you don’t want the enemies to collide with each other.
Set the layers of your Enemys to an individual layer.
In "Edit/Project Settings/Physics2D/Layer Collision Matrix" disable the collision of the Enemy layer with the Enemy layer.
Your answer
Follow this Question
Related Questions
Problem with a multi-jump script ( C# ) 1 Answer
LookAt in 2d is not working Again :/ 0 Answers
Why does FixedUpdate stop working? 1 Answer