expressobits / character-controller

Modular Character Controller for Godot 4. Includes FPS version with headbob and camera movement. (Walk, Crouch, Sprint, Swim and Fly Mode).
https://godotengine.org/asset-library/asset/1567
MIT License
319 stars 13 forks source link

Update CharacterController3D for modularity #19

Open Blade67 opened 1 year ago

Blade67 commented 1 year ago

The current CharacterController3D requires constant updating when adding new features. This proposal proposes to update the behavior in favor of a more dynamic approach.


Signals

Instead of individually creating new signals for each ability inside of the CharacterController3D class, either create them dynamically using the native add_user_signal function, or declare them inside the ability and make the CharacterController3D connect to them dynamically.

Properties

Properties should be ability-bound, thus visible from the editor under the abilities_path array, when selecting the ability. This would however require the abilities to be resources, potentially making this a major undertaking.

Emitters

Emitting signals should be done from within abilities and not on the CharacterController3D.

TL;DR

Each ability should only take care of themselves, independently (or co-dependent of another's ability by connecting to it directly) of others. This allows more complex behavior and abilities being more than just movement related. (ie. interaction handling, etc.)

scriptsengineer commented 1 year ago

This can really be a design problem, at the beginning of the project I strictly followed the rule that child nodes should not know about their parents when developing the character controller. Reviewing some concepts like the one presented by GDQuest about StateMachine, maybe it could be easily applied here and without the need to put skills as a resource.

However, there is still a way to use new abilities on your character, which is to extend the character script and implement the new abilities, rewriting functions if possible.