Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | shoeberto | |
Old Version | Published before Godot 3 was released. |
I have a hierarchy of entity classes where I need to be able to act on collision information differently per entity type, but I’m very confused about how _fixed_process() actually operates in the inheritance structure.
Basically, I have a higher-level entity class (SpriteEntity) that is used to handle basic motion & animation for my entity scenes, and I am now working on a subclass of it for the player character (PlayerCharacterEntity). These scripts are attached to KinematicBody2D nodes. Right now I just want to make it so that, if a PlayerCharacterEntity walks into a SpriteEntity, I can detect it and do something with it.
My confusion is mostly with how _fixed_process() works. In most languages, I would expect that by subclassing and overriding a method, I would have to explicitly invoke the base class method, but _fixed_process() appears to fire on the base class regardless. This makes the logic confusing, since when the SpriteEntity movement code is called, it will correctly detect collision, but it appears that the PlayerCharacterEntity code has only occasional knowledge as to whether a collision has occurred (race condition?)
I’ve been banging my head against this for a few days and really haven’t come out with any more understanding. Why does _fixed_process() seem to get called independently on all scripts in a class hierarchy, and how can subclasses have knowledge of collisions that are reported in a base class?