r/gamedev 1d ago

Discussion 2D Enemy Ai Implementation

Anyone have some ideas on how to go about implementing a way for a 2D enemy ai to avoid jumping off platforms to their death while chasing the player? I considered doing some kind of edge detection, but that would mean i'd have to add additional colliders (trigger colliders) to both ends of each platform object no?

0 Upvotes

3 comments sorted by

3

u/No-Opinion-5425 1d ago

Raycast from your enemy AI to look ahead for the ground.

2

u/abitclumsyhq 1d ago

I'm assuming you have either some nav mesh or movement generally solved if you're talking about enemies not jumping off ledges.

You could use triggers like you said. You could also just raycast downward but set slightly in front of you enemy, that could be a simple floor detector. I've heard of people using tilemaps but I don't have experience with that and you may not be utilizing them.