Godot Version
Question
in this top down game, I want the player stop moving when he wants to aim and shoot his gun, the problem is, if he is moving and presses the aim button at the same time, the player just moves and doesnt stop. here is the code for movement and aim mechanic:
var aim=false
const max_sp=100
const aimsp=0
var sp=max_sp
enum {IDLE, RUN}
var state=IDLE
func move(delta):
var input_vector
if aim==true:
pass
if aim==false:
input_vector = Input.get_vector("ui_left","ui_right","ui_up","ui_down")
print(input_vector)
if input_vector==Vector2.ZERO:
state= IDLE
else:
state=RUN
apply_move(input_vector*Accel*delta)
blend_pos=input_vector
move_and_slide()
if Input.is_action_just_pressed("aim"):
aim=true
sp=aimsp
state=IDLE
if Input.is_action_just_released("aim"):
aim=false
sp=max_sp
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and aim==true:
var dir= get_global_mouse_position()-position
shoot.emit(position,dir)