0

I am making a game in P5JS (A framework of JavaScript) and I've run into a problem. I have enemies who are all circles as of right now and they are stacking since they go straight to the player. I need the enemies to not stack on top of each other, I have an X and Y for every character and here's a rough sketch of what I'm trying to accomplish.

Sketch

The 2 orange dots are enemies and the blue dot is the player. I drew a blue and green line to show which way they are trying to go and since every enemy is gonna go different speeds, they would overlap and it wouldn't make much sense if they were on top of each other plus it's more difficult to play that way.

I need the outer enemy to go to where the purple dot is (rough estimate of the position). What math would you suggest I do?

  • Collision detection? Avoidance “AI”? – evolutionxbox Apr 19 '20 at 00:56
  • see [Path generation for non-intersecting disc movement on a plane](https://stackoverflow.com/a/30639417/2521214) read the whole stuff (Q and all Answers !!!) then chose the way you want to code – Spektre Apr 19 '20 at 09:31

1 Answers1

0

I solved my own problem.

I had to add a custom rigid body function to my players that pushes them and acts as a physical object. You push them perpendicular to the tangent intersection point and that makes it react more fluid.