Abstract classes plus abstract methods (EnterState)

Another great thing about abstract classes is the ability to make the methods in them abstract. I think EnterState() would be a great example of when to do this - since it doesn’t do anything, but it’s expecting the inherited classes to do something, making it abstract will force the inheriting classes to implement it.

1 Like

This also could have been expanded further and used to remove the Godot Notifications. If we told our StateMachine that the current state and array of states are of type State which implemented the EnterState method we could have called EnterState directly in the StateMachine rather sending a notification to the abstract class to call it’s own EnterState method.

Privacy & Terms