AI Mob Movement with Moving Platforms

dhouseley

Member
Hello,

I have adopted the RTS Group movement system found in the marketplace to create the effect of mobs of units moving towards a single goal (the Player). It works beautifully for moving units and moving them around objects. The only issue I am having is when I try to move a unit around a moving platform. Essentially the point of the game is for the player to move side to side to cause the mob following him to run into obstacles and keep them at bay.

Has anyone had experience with unit collision with moving objects while using a pathfinding system?

I would appreciate any help, attached is the bones of the project.
 
I won't go into all the code, but for my AI all the objects are moving and need to be avoided. To do this I basically find out where the avoiding object is in relation to the moving object, and assign four corners to the moving object - each corner is a spot with half of the avoiding objects dimensions added to it (origins are all centred), and a little bit extra just to be sure.

Then it's a bit of legwork figuring out what corners it needs to go around, and putting them in an array.

After that I build a path by using two scripts (found on GMLscripts.com) that find this information:
1) The angle required for a moving object to hit another moving object (in this case the defined corner you want to reach) - the script is called "intercept_course" and is found under 'gameplay' / /artificial intelligence'
2) The distance / time to interception - "instance_closest_approach" found under 'gameplay' / 'instances'

By using the first script you find which direction to head in to hit the target point, and the last script tells you at which point the two objects will be when this interception happens. You then need to work through the remaining corners, making sure to account for where objects end up after each calculation, until you have passed around the moving object.

As I said before, this part really comes down to you figuring out those points to pass by yourself. It works for me, but maybe someone else has a better suggestion....
pass.png
 
Last edited:
Top