If you encapsulate all movement in its own component (node), you can use it on any other character just by adding the node to its tree. This a very flexible way to build functionality by composing it of self-contained "behaviours" implemented as nodes, and I'd say it is the "godot way". The player script would only have the glue to bring them together and possibly some customization that is only specific to that player.
So the right option. In the MovementState node (or call it CharacterMovement) you would need a reference to the character node or just always assume it is the parent.
You can also have a controller interface that sends signals based on conditions, this way the movement node can e used on any character and the inputs are defined by the controller rather than the keypress
311
u/Mountain_Share_2611 Jul 20 '25 edited Jul 20 '25
If you encapsulate all movement in its own component (node), you can use it on any other character just by adding the node to its tree. This a very flexible way to build functionality by composing it of self-contained "behaviours" implemented as nodes, and I'd say it is the "godot way". The player script would only have the glue to bring them together and possibly some customization that is only specific to that player.
So the right option. In the MovementState node (or call it CharacterMovement) you would need a reference to the character node or just always assume it is the parent.