buzzbuzz20xx your problem is you are not using a state machine.
a state machine is simple, you have a variable that represents the state of the object, in this case 0 would be player can move and shoot, and 1 would be player is dead.
var state : int = 0
and then when pressing the button you have to check if the state is 0, otherwise do nothing
if state == 0:
fire()
func input_event(event):
if state == 0:
if event.is_action_pressed("Fire"):
#etc etc etc
so when the player dies, the state has to be set to 1.
there are other problems with your code, for some reason you are making the game spawn shots from OUTSIDE the player. I would instead put a function in the player that when executed does the shooting.
you should also always check if a reference exists before using it, you can do it this like:
if player:
#do something
or
if player != null:
#do something
also don't overuse signals, they are good but for some reason tutorials LOVE using signals for everything, even when signals are redundant. Then something like this happens.
when using signals you have to be very careful.
func shooting():
var new_bullet = bullet.instance()
add_child(new_bullet)
new_bullet.position = $Player.position
new_bullet.rotation = $Player.rotation
$laser_sound.play()
no. put your player in a reference.
@onready var player = $Player
@onready var laser_sound = $laser_sound
func shoothing():
if player:
var new_bullet = bullet.instance()
add_child(new_bullet)
new_bullet.position = player.position
new_bullet.rotation = player.rotation
laser_sound.play()
func _on_Player_area_entered(area):
emit_signal("player_killed")
get_tree().get_root().set_disable_input(true) #i tried putting this here but it didn't do anything
set_process_unhandled_input(false) #and this one did nothing either...
queue_free()
no. you are already emitting a player_killed signal, just change the state when the signal is received by the input node.
In the input, check if the state is 0 before executing any code.
If the player_killed signal is received, change the state to 1.