Child nodes to place more than one script?

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

I’ve been using Godot for a few days, and from what I’ve seen, it only accepts one script per node.

I am creating a state machine (FSM) for the player, each state is a different class with its own properties (exports).

The ideal would be to add a node for each state in order to see its [export] properties.

My question is, if I add a child node, will the engine do unnecessary positioning and rendering calculations? is there some kind of “fake” node?
what is the “best-practice” to do this in Godot?


:bust_in_silhouette: Reply From: KohuGaly

Technically yes, the engine will have to combine the position and orientation of the parent with the child (child nodes are positioned relative to parents). However, that’s not really something to worry about, as far as performance is concerned.
As for rendering, the scene tree determines order of rendering in 2D, but that’s pretty much it. Unless the parent node actually does some rendering of its own, there shouldn’t be any extra rendering calculations.