Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | unfa |
I would like to define some classes of objects inheriting properties and methods to organize the objects and scripting of my game. For example:
Character - extends KinematicBody. Has health, can take damage and respond to healing
Player - extends Character. Can pickup objects and respond to user input
Enemy - extends Character. Has an AI-driven behaviour.
Trigger - has collision, activates other objects on contact with a Player node
Pickup - detects collisions with Players, grants them health or items
HealthPickup - extends Pickup - heals players on contact
WeaponPickup - extends Pickup - grants a selected weapon to a Player on contact
AmmoPickup - extends Pickup - grants ammo of selected type and amount to a Player on contact
And so on…
I guess Godot has great tools to do this, but currently I have no idea how to organize my code and objects using this “tree” logic.
I’ve been reading up on classes, duck typing etc, but I’m still completely oblivious to how I can make this work for my game.