Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | thoma |
Hi, I have two function one it reload and another it shoot but thing is I do not know how I can set my reload function false when the player do the function shoot. I try few thing but it did not work and I am stuck whit a player can soot and reload at the same time
here the code:
shoot:
func shoot():
if ammo !=0:
ammo-=1
emit_signal("ammo_changed",ammo *150/max_ammo)
can_shoot = false
$timer.start()
$Player/anime.play("shoot")
yield($Player/anime,"animation_finished")
$Player/pewpewpew.play()
var pew = pewSCN.instance()
get_parent().add_child(pew)
pew.position =$Player/Position2D.global_position
pew.rotation = $Player/Position2D.global_rotation
function reload:
func reload_true():
ammo=max_ammo
and my Input use this two function:
func _physics_process(delta):
if Input.is_action_just_pressed("reload"):
reload_true()#set the shoot function false
emit_signal("ammo_changed",ammo *150/max_ammo)
if (Input.is_action_just_pressed("shoot")&&can_shoot):
shoot()#set the reload function false
Thank for helping me