M
maranpis
Guest
Hello guys:
I was trying to figure out in GM2, how to perform a melee attack in the air maintaining the gravity and the previous horizontal and vertical speed.
At the moment when I perfom the attack in the air the player stops in the air and execute the animation.
This is the moving script
and this is the Global Left mouse Pressed event
This is the animation End event
¿Where and how can i set the conditions to perform the attack maintaining the gravity and the previous horizontal and vertical speed?
Thanks for your help
I was trying to figure out in GM2, how to perform a melee attack in the air maintaining the gravity and the previous horizontal and vertical speed.
At the moment when I perfom the attack in the air the player stops in the air and execute the animation.
This is the moving script
Code:
if attack=false
{
//MOVE RIGHT AND LEFT
if keyboard_check(vk_right)
{
hospeed=20;
sprite_index=s_Running
image_xscale=1;
mask_index=rough_player;
}
else if keyboard_check(vk_left)
{
hospeed=-20 ;
sprite_index=s_Running
image_xscale=-1;
mask_index=rough_player;
}
else
{
hospeed=0;
sprite_index=s_Idle;
mask_index=rough_player;
}
//GRAVITY AND JUMPING
if !place_meeting (x,y+1,o_Ground)
{
vespeed+=grav
sprite_index=s_Jump;
mask_index=rough_player;
}
else
{
if keyboard_check_pressed(vk_up)
{
vespeed=-20;
sprite_index=s_Jump;
mask_index=rough_player;
}
}
}
// COLLISION X
if place_meeting(x+hospeed,y,o_Ground)
{
while !place_meeting (x+sign(hospeed),y,o_Ground)
{
x+=sign(hospeed);
}
hospeed=0;
}
x+=hospeed;
// COLLISION Y
if place_meeting(x,y+vespeed,o_Ground)
{
while !place_meeting(x,y+sign(vespeed),o_Ground)
{
y+=sign(vespeed);
}
vespeed=0;
}
y+=vespeed;
Code:
if attack=false
{
attack=true;
sprite_index=s_Attack;
image_index=0;
mask_index=rough_player;
}
Code:
if attack=true
{
attack=false;
script_execute(Move_state);
}
Thanks for your help