Reputation: 85
So i am trying to make a 2d platformer but i am having trouble with the ai. I can make the enemy follow me around perfectly when we start on the same platform but not when we start at the opposite side of the map like so.
https://i.sstatic.net/UJeNe.jpg
so i want the enemy to jump because there is no platform below. What would be the best way to let the ai know where and when to jump?
Upvotes: 0
Views: 211
Reputation: 119847
Just think of the platforms as nodes that are connected. If you had a bottom platform, both top and bottom would be "choices" for the AI when it reaches the edge of the left/right platforms. There, your platform should contain data to which platforms is it connected to.
You might want to add some data on your platforms like level/height so the AI knows what it should do when it transitions from platform to platform, whether it should jump up to the next plaform or just drop down.
Upvotes: 1