Adding behaviors in CGE editor (TCastleBillboard, TCastleSoundSource)

Posted on

Design: Werewolf, from a sprite sheet, is also a billboard and emits a 3D sound
Werewolf, from a sprite sheet, is also a billboard and emits a 3D sound

You can now add/remove behaviors using the CGE editor. “Behaviors” are components that enhance the behavior of the parent TCastleTransform. We have a few of them included in CGE, and you can define more (“3D FPS Game” template shows a trivial behavior of an enemy).

If you come from Unity, know that “creating TCastleBehavior” is now the closest equivalent to Unity “creating MonoBehaviour”.

The behaviors you can add now using the editor are:

  1. TCastleBillboard. Turns any TCastleTransform into a billboard (visually, in the editor, too). Billboard automatically rotates (around some axis, or freely) to face the camera. TCastleBillboard is now our advised way to make billboards in CGE (much simpler to use than X3D node TBillboardNode, which we advised in the past).

    It exposes AxisOfRotation, by default +Y axis. Simply set it to zero Vector3(0, 0, 0) to rotate the transformation freely, to always face the camera.

  2. TCastleSoundSource. This makes the parent TCastleTransform emit a sound. Such sound has a 3D position and can be spatialized, which means that distance of the emitter affects the volume, and position of the emitter affects whether you hear it more from the left or right side. More on this in later news about sounds 🙂

A simple example of it is now in examples/creature_behaviors. The wolf is a sprite sheet, and a billboard, and it emits a “howling” sound.

Start the discussion at Castle Game Engine Forum