• 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!

Locking the Player in Place for a Couple of Seconds

For the past couple of days, I been working on a dodge mechanic in which the player will need to dodge projectiles from the enemy What should happen is when the button is pressed, the player should not be able to move for a split second. He does go into the state, but he is able to move around freely which is not the intent.

GML:
function scr_newflarecontrollerinput(){
   
    //Player Input
key_right = keyboard_check(vk_right);
key_left = keyboard_check(vk_left);
key_up = keyboard_check(vk_up);
key_down = keyboard_check(vk_down);
key_jump = gamepad_button_check_pressed(0,gp_face1) + keyboard_check_pressed(vk_space);
key_shoot = gamepad_button_check(0,gp_face3) + keyboard_check(vk_control);
key_lock = gamepad_button_check(0,gp_shoulderl) + keyboard_check(ord("Z"))
key_dodge = gamepad_button_check_pressed(0,gp_face4)

   
    //GamePad Controllers
   
    if (abs(gamepad_axis_value(0,gp_axislh)) > 0.2)
{
    key_left = abs(min(gamepad_axis_value(0,gp_axislh),0));  
    key_right = max(gamepad_axis_value(0,gp_axislh),0);
}


var move = key_right - key_left

hsp = move * walkspd
vsp = vsp + grv;




    //Direction with Analong Stick
   
    dir = point_direction(0, 0, gamepad_axis_value(0,gp_axislh), gamepad_axis_value(0,gp_axislv))

}


GML:
function scr_newflareidle(){
   
    scr_newflarecontrollerinput()
   

    if hsp > 0 || hsp < 0
    {
    move = 1
     flare = flare.move
    }
   
    if place_meeting(x, y+1, obj_wall) && (key_jump)
    {
    vsp = -jumpspeed
    ground = false
    flare = flare.jump
    }
   

    if (key_dodge)
    {
    move = 0
    hsp = 0
    key_jump = 0
    dodge = true;
    flare = flare.dodge
    }
   
    if (key_lock)
    {
    move = 0
    flare = flare.lock
    }

Step Event

GML:
scr_newflarecontrollerinput()



if place_meeting(x, y+1,obj_wall)
{
ground = true;  
}

switch(flare){
case flare.idle: script_execute(scr_newflareidle); break;
case flare.move: script_execute(scr_newflaremove); break;
case flare.dodge: script_execute(scr_newflaredodge); break;
case flare.jump: script_execute(scr_newflarejump); break;
case flare.fall: script_execute(scr_newflarefall);break;
case flare.lock: script_execute();break
}



scr_collision()
 

Pixel-Team

Master of Pixel-Fu
On your flare switch statement, only call the scr_newflaremove script if dodge is false.
 
Last edited:
Top