I'm done with "boolean check"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mrpaolosarino

Seriously , I’m done with this kind of code:

var can_proceed = true
func _process(delta):
     if can_proceed == true:
             play_this()
             can_proceed = false

I know this works when making a call “one_shot” but jeez, is there any alternative to this?

You do not need to compare the boolean to true explicitly. The following is sufficient:

if can_proceed:
    play_this()
    can_proceed = false

Calinou | 2021-07-02 14:47

:bust_in_silhouette: Reply From: Spyrex

If you want to run the play_this() function directly after loading, but don‘t have to react to the can_proceed variable the _ready() function will do the job. If you want to react to a variable change I would suggest to use a setter . Just look up the setget keyword.