I've run into an issue with an agar.io clone minigame I'm implementing into my game. I have it working where if the player is 1.25x the size of an ai, the player absorbs it. However, I hit a snag when trying to make the ai be able to eat each other as well.
The event for the player eating Ai is as follows:
player on collision with npc | Player add npc.mass to mass
player.mass > npc.mass*1.25 | Npc set mass to 0 (there's another event that destroys an npc when mass = 0)
However, when I make this event affect npcs vs npcs:
npc on collision with npc | npc add npc.mass to mass
npc.mass > npc.mass*1.25 | Npc set mass to 0
whenever the npcs touch each other, they both are destroyed, regardless of size. I'm assuming it's because cs doesn't know which npc I'm referring to in either instance. Is there a way to fix this? I've done a little research, to no avail. Thank you!
Bonus question: How do I make the ai run away from the player, as well as each other npcs if they're bigger than 1.25x their own mass? They're using pathfinding and LOS. Right now I have them pathfind to a random point in the layout, but more often than not they just run right into the player, getting absorbed.
I'd also like a little help on keeping the npcs from bunching up or chasing the same food, as well as something to detect when the food they're chasing has already been eaten by someone else.