• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML (SOLVED)Flying/Hovering Enemy A.I. Motion Planning (Like in Super Create Box)

KamilSeven

Member
Hi!
I want to build a flying enemy motion planning for a side view game (Super Crate Box clone for learning purpose). I've tried using a simple motion planning line to achieve it. But the issue is, mp is creating the shortest path to the target, so it doesn't give the effect of flying/hovering to the character.

Here is an example of what I'm trying to achieve. Flying skull enemies and the way they hover and bounce while following the player position.




My simple code was based on Let's Learn GameMaker: Studio's tutorial.
I tried to tweak mp settings but couldn't get the result I'm after.

GML:
///Mp Potential

goalx = obj_player.x
goaly = obj_player.y

//rotation in a step
var maxrot  = 15;

//Check for collision

var rotstep = 10;

//Planning ahead

var ahead   = 3;

//Rotate on spot

var onspot  = true;


mp_potential_settings(maxrot,rotstep,ahead,onspot);

mp_potential_step_object(goalx,goaly,stepsize,obj_wall);
 
Last edited:

samspade

Member
I don't think motion planning would be the way to go here. Watching the video it really seems like all they've done is lower gravity on the 'floating' skull and giving the skull a larger hitbox than the the image (so that the skull collides with the platform 'before' actually hitting it) and then applied either a bounce or a jump when the skull hits the platform.
 

KamilSeven

Member
I don't think motion planning would be the way to go here. Watching the video it really seems like all they've done is lower gravity on the 'floating' skull and giving the skull a larger hitbox than the the image (so that the skull collides with the platform 'before' actually hitting it) and then applied either a bounce or a jump when the skull hits the platform.
Thank you for your response. I'll try to build the logic, based on your comment. It is really just a hobby for me, every idea just pops another question mark about how to do it when it comes to coding.
 

KamilSeven

Member
How can I make the enemy follow the player and avoid obstacles without using motion planning? I really don't know where to start.
 

samspade

Member
Sure. So the reason I would avoid built in motion planning for something like this is that is really intended to work on a top down perspective. So if you are trying to do a platformer, it wouldn't have the desired result.

While seeking the player in a platformer becomes complicated really quick if you want the AI to be able to move up, falling down is easy.

What collision code does your player use? Likely you enemies could use the same. In fact, the core of a player's movement and collision generally is identical to the core of an enemies movement and collision. The big difference is that the player object will get input from the player and the enemy does not. In the example above, the enemy just sets its hsp based on whether it is to the left or the right of the player (e.g. hsp = player.x - x).
 

KamilSeven

Member
It's been a while. I found the source code for SCB. I can't run it; I guess it was made in GMS:1.3, but the whole code is there. I'll take a closer look at the logic behind the flying entity.
 
Top