2

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!

  • I'll probably need some explanation in the variables used before I'll be able to answer it. what means `controllerhr`, `controllervr`, `controllerh`, `controllerv` and `inuse`? – Steven Sep 24 '19 at 09:43
  • 1
    @Steven the controller h, v, and their r variants are the rotation of those axis on their respective planes, any ways I found a solution, for some reason the shoot action being on the right stick made it skip over in the order or something, so moving the shoot if into the left stick worked. Also inuse was a variable I forgot to remove and it was for testing if the right sticknwas inuse or not. – Skadoodlefap Sep 25 '19 at 12:02
  • Alright. Glad to hear you found a solution. You can post your solution as an answer and mark it as solved, that could help future visitors. – Steven Sep 26 '19 at 06:39

1 Answers1

0

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.