All Questions


Zythaar Anonymous
posted to: The battery

Possible optimization?

## A faster method would be `get_node()`, which only tests one path.
onready var _power_direction := find_node("PowerDirection")
Why not use get_node_or_null() it should be as fast as get_node() but without throwing an error?
  • Nathan Lovato replied

    Sure, why not. At the time of writing, I think the method wasn't available yet.

    As far as performance goes it won't make a difference here: at most we have two or three nodes in those scenes if I remember correctly.

  • Razoric replied

    Apparently it got introduced in Godot 3.1, I just didn't know about it at the time.

    It only happens once per object, so it's something of a micro-optimization, but it would be the better function to call in the future :)