Luke Pierson
Member
Hello GMC! I've been curious for a while about how to make a jumping enemy ai in a sidescrolling game. Haven't found any tutorials on it yet. I'm thinking of anything from a dog, spider or even a knight that will leap at the player to attack. I'm certainly aware of states and whatnot, I just need to figure out how one would do this? Here's the gravity/collision codes for my current game:
collisions:
gravity:
Any help for figuring how exactly to go about this would be awesome!
collisions:
Code:
///move
// Horizontal collisions
if (place_meeting(x+hspd, y, SolidParent)) {
while (!place_meeting(x+sign(hspd), y, SolidParent)) {
x+=sign(hspd);
}
hspd = 0;
}
x+=hspd;
// Vertical collisions
if (place_meeting(x, y+vspd, SolidParent)) {
while (!place_meeting(x, y+sign(vspd), SolidParent)) {
y+=sign(vspd);
}
vspd = 0;
}
y+=vspd;
Code:
///apply_gravity
if (!place_meeting(x, y+1, SolidParent)) {
vspd += grav;
}