Today’s news is a combo of new things 🙂 I am back from 1.5 weeks of conferencing (first in Germany then in Poland). I have fresh energy, new demo and slides for you to enjoy!
- First of all, I have merged to CGE master branch an initial design of
TCastleMoveAttack
component that allows to easily define a creature AI. The idea is to attach this behavior to anyTCastleTransform
and make it behave like a typical FPS games enemy — it will walk toward (configurable) enemy, it will make a short range attack, it will run away from enemy when low on health etc.It cooperates with the
TCastleLiving
behavior that represents something that has hit points and can be dead / destroyed. You will typically addTCastleLiving
to each enemy (otherwise enemy is indestructible) and to the player (camera or avatar, depending on if you make a 1s-person or 3rd-person view).It is configurable what is the enemy for each
TCastleMoveAttack
— they can track and attack anyTCastleLiving
. So they can attack the player, or fight with each other — lots of fun possibilities!There are some important TODOs remaining to be finished in this regard, so I emphasize that the way this component works will change (in particular, the movement will change to follow physics). Do not use it yet for bigger projects — though you can certainly use it already to have some fun 🙂 I also emphasize that this is not the only way to make enemies logic in Castle Game Engine — you can always code your own logic, creating new behaviors (see e.g. “3D FPS Game” template for a starting point).
The existing documentation for now is in API reference of CastleLivingBehaviors unit and you can take a look what the examples do:
- Enjoy the new demo project mentioned above from “Zlot Programistów Delphi”: Demo game using Blender, Sketchfab, Quaternius models, TCastleMoveAttack.
It’s a complete game with level designed using Blender, level props from Sketchfab, enemies from Quaternius, enemy logic using
TCastleMoveAttack
andTCastleLiving
. The game code shows simple things like game “win” (you “win” the game when you reach a certain invisible box in the level), game “lost” (when player’s life drops to zero), walking with mouse look, shooting at enemies.The example is naturally compatible with both FPC/Lazarus and Delphi.
-
Finally, the slides from my presentation at “Zlot Programistów Delphi” 2024 are available.
Note that they are in Polish, as the event is mostly in Polish. If you have trouble translating anything, and want to learn it, just let me know 🙂 Some of the topics overlap with slides I used for my Cologne lecture so you can find some explanation there too.
Start the discussion at Castle Game Engine Forum