Parting Animation from Player

In the video it’s said that the player script should not handle animation. Player.gd is still calling animation updates. Wouldn’t it be cleaner if animation gets the motion from its parent?

In C# I would use an interface like IMoveable so that I can get sure, that the animation script only animates, if the parent has a motion. Are there similar things in GD-Script?

It may be cleaner using interfaces but gdscript doesn’t support it, because gdscript supports “duck typing”, which is explicitly recommended in the documentation: https://godot.readthedocs.io/en/stable/learning/scripting/gdscript/gdscript_advanced.html#duck-typing

You can use duck typing to make interface/abstract class kind of behavior for example like this:

if obj.has_method("func_name"):
    obj.func_name()

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

Privacy & Terms