![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Bárbara Gabriela |
I am trying to make a node appear on the side of the player and the player changes animation when pressing enter, but while it is in the second state it continues to spawn until pressing enter again. I just want it to appear once.
Here is the code:
#states variables
const slimezinho = preload(“res://scenes/slimes/slimezinho.tscn”)
onready var state = $player_sprite
var state_now = 1
#change state
if(Input.is_action_just_pressed(“enter”)):
state_now += 1
#change sprite
if(state_now == 1):
state.play("slime")
elif(state_now == 2):
state.play("slimezinho")
var slime = slimezinho.instance()
get_parent().add_child(slime)
slime.set_position(get_node("spawn").get_global_position())
elif(state_now == 3):
state.play("mini_slimezinhoinho")
elif(state_now > 3):
get_tree().reload_current_scene()