I
IsraelKaveski
Guest
So, i making a game plataform and my enemies can walk on objects and fall.
However, I would like that while they were falling, change their angle (to be more realistic) and when it touches the ground again, stay with the same starting angle.
This is the code i was using:
//gravity system
if (place_free(x,y+spdfall)){
y+=spdfall;
spdfall+=grvt
if (spdfall > maxspdfall){
spdfall = maxspdfall
}
} else {
spdfall = 2;
while(place_free(x,y+1)){
y++;
}
}
//Movement System
if(dir == 1){
if(place_free(x+4,y))
{
x+=2;
}else{
dir=-1;
image_xscale = -1;
}
}
if(dir == -1){
if(place_free(x-4,y))
{
x-=2;
}else{
dir=1;
image_xscale = 1;
}}
Event Create:
dir = 1;
spd = 4;
spdjump = 8
grvt = 0.4;
spdfall = 2;
maxspdfall = 8;
jump = false
jumpheight = 128;
jumpframes = 0;
However, I would like that while they were falling, change their angle (to be more realistic) and when it touches the ground again, stay with the same starting angle.
This is the code i was using:
//gravity system
if (place_free(x,y+spdfall)){
y+=spdfall;
spdfall+=grvt
if (spdfall > maxspdfall){
spdfall = maxspdfall
}
} else {
spdfall = 2;
while(place_free(x,y+1)){
y++;
}
}
//Movement System
if(dir == 1){
if(place_free(x+4,y))
{
x+=2;
}else{
dir=-1;
image_xscale = -1;
}
}
if(dir == -1){
if(place_free(x-4,y))
{
x-=2;
}else{
dir=1;
image_xscale = 1;
}}
Event Create:
dir = 1;
spd = 4;
spdjump = 8
grvt = 0.4;
spdfall = 2;
maxspdfall = 8;
jump = false
jumpheight = 128;
jumpframes = 0;