Makin a trophy system, signal constantly triggering

Godot Version

4.2

Question

How to call a signal once but it needs to check variables and change a state from false to true also?

Trophy flags must start false

var star_points_trophy = false
var plant_pot_trophy = false

Trophy flags end

func _ready():
connect(“trophy_signal”, add_trophy)

func _process(_delta):
star_point_trophy()
plant_pot_amount_trophy()

Trophy Conditions

func star_point_trophy():
if Coins >= 2001:
star_points_trophy = true
emit_signal(“trophy_signal”)

Trophy Conditions end

func add_trophy():
var instance = newtrophy.instantiate()
get_parent().add_child(instance)

If I am understanding the problem you want to give the player a trophy but only once:

func _process(_delta):
    if !star_points_trophy:
        star_point_trophy()
    if !plant_pot_trophy: 
        plant_pot_amount_trophy()

Oh wow, now I feel like a fool. I didn’t think of setting a boolean like this. I use them in another project I am tinkering with that has faux user passwords that need to check each other. Thank you for helping me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.