#Enemy Pathing?

1 messages · Page 1 of 1 (latest)

graceful pelican
#

Hello guys I'm super new to game developing and i still try to learn and do most with ChatGPT as a helper but I'm stuck like over 8 hours and need help....
Top Down 2D Game
So the idea is:
Enemies always track the player and follow him till they are in attack range that works problem is I don't want them to push each other and if they realize there is an enemy in front of me I dodge that enemy and get another position next to the player.
Just imagine LoL melee minions surrounding a Tower or Starcraft 2 Zerglings (or any other melee unit) surrounding a building or an enemy. That's my goal but it just doesnt work either way its clunky or they push each other to get close to the position etc... idk what to do

i just post every code i use so far for my enemy if u wanna see anything else let me now

Player and Zombies are both just circles with circle collider and dynamic body type player has the player 1 tag and zombie the enemy tag so yeah idk anyone a idea?

thick slate
#

"Enemies always track the player and follow him till they are in attack range that works problem is I don't want them to push each other and if they realize there is an enemy in front of me"

You'll need to look up agent local avoidance. I don't use Unity's pathfinding module much and I recall it being pretty bad when the local avoidance target is another agent.

#

Learn how NavMeshAgent obstacle avoidance works... in DEPTH! In this deep dive into NavMeshAgent avoidance you'll learn 5 key takeaways for improving NavMeshAgent avoidance using the Unity Navigation System - no external assets needed!

Learn how:
⚫ NavMeshAgent Avoidance Quality influences avoidance
⚫ NavMesh Prediction Time values influen...

▶ Play video
graceful pelican
#

problem is with 2d top down game there is no navmesh as far as i know + just avoidance is also a problem i need to change thme to is trigger which makes them run into each other or i crank the settings pretty high but that looks abnormal..

thick slate
#

Oh apologies I keep forgetting unity does not support 2D nav agents /shrug

#

Local avoidance is a science and there's many resources out there for it

#

Ok what you have there is very basic. Everything seems to just charge towards a target without any sort of navmesh or pathfinding alg

#

So a very crude idea here is have every enemy raycast forward every so often when they are only a couple of units away from the player. This way you can start scattering them as they reach the point. If an enemy does detect another enemy is in front of them, let them diverge off the target path until they stop detecting any enemy in front of them

#

Such that you add some velocity to the left or right of the target direction

graceful pelican
#

thanks for the reply im making a break rn but i will look towards it!

graceful pelican
ocean blade
#

it could easily take you a month to figure all of that out

graceful pelican
#

well i get some progress so 27 days to go lets go haha

ocean blade
#

did you understand what i mean by emergent

graceful pelican
#

no there is no real 2d navmesh as far as i know i think i read something about a "fake" 2d navmesh but that sounded complicated for a first try on a game. and yea i think i got what you mean but as far as i know league minions are pretty straight forward the problem i mainly have is collision and stuff cause i dont want them to run into each other to shove me or other zombies around so they need to avoid them

ocean blade
#

if there are characters moving around a real world, you want to model your world, even if it is a "2d game", as objects in the xz plane with 3d physics colliders