gmlgame-maker-languagegame-maker-studio-2

Game Maker Studio 2 - How to give one input priority over another when controlling the same object?


I'm trying to control an aiming object in a game I'm starting on with two different inputs, one is the left stick so you can aim while moving, and one is the right stick for more precise aim, but I'm having trouble making it so I can control it with the left stick while still moving with the right stick.

I've already tried reordering the code and having a variable to check if the left stick is in use or not, but none of that worked.

if abs(controllerhr) > 0.2 or abs(controllervr) > 0.2{
controllerangle = point_direction(0,0,controllerhr,controllervr)
}
if gamepad_button_check_pressed(0,gp_face3) or gamepad_button_check_pressed(0,gp_shoulderrb) and firingdelay < 0 and ammo > 0{
firingdelay = 4;
ammo -= 1;
oPlayer.hsp-= lengthdir_x(playerrecoil,image_angle);
oPlayer.vsp-= lengthdir_y(playerrecoil,image_angle);
with instance_create_layer(x,y,"Kunai",oKunai){
speed = 15;
direction = other.image_angle;
image_angle = direction;
}
image_angle = controllerangle
}
}



if oPlayer.controller==1 and inuse==0{
if abs(controllerh) > 0.2 or abs(controllerv) > 0.2{
controllerangle = point_direction(0,0,controllerh,controllerv)
}
image_angle = controllerangle
}

P.S. It is indented correctly The indentation just messed up while pasting.

Thanks!


Solution

  • I found a solution, for some reason the shoot controlls were skipping over the code or messing up the ordering or something, so moving the shooting code to the left stick changed the ordering and that fixed it.