This page is not the current release of O3DE documentation. Click here to switch to the latest release, or select a version from the dropdown.

Version:

Common Tasks, EBuses, and Handlers

The following are some common game programming tasks and the EBuses and handlers that you can use to implement them.

Detect Mouse, Keyboard, or Other Button Events


BusAZ::InputEventNotificationBus
EventsOnPressed, OnHeld, OnReleased
FileInputEventBus.h

Use these events to detect when mouse, keyboard, or other buttons are pressed, held, or released.

Detect Entity or Component Readiness


BusLmbrCentral::MeshComponentNotificationBus
EventsOnMeshCreated, OnMeshDestroyed
FileMeshComponentBus.h

Even after an entity has been created and its components have been activated, visual data might not be fully loaded. The OnMeshCreated event occurs when the mesh creation is complete. This is useful if you want to access the underlying ICharacterInstance and ISkeletonAnim members in order to play animations. More generally, it is useful to declare a component or entity as “alive” or game ready, whatever that might mean for your application.

Get and Set Physics Characteristics


BusLmbrCentral::PhysicsComponentRequestBus
MethodsAddImpulse, GetMass, SetMass, GetVelocity, SetVelocity, etc.
FilePhysicsComponentBus.h

The PhysicsComponentRequestBus contains useful methods for getting or setting the physical characteristics of objects like mass, density, velocity, and water damping.

Get Notifications for Animation Events


BusLmbrCentral::CharacterAnimationNotificationBus
EventOnAnimationEvent
FileCharacterAnimationBus.h

If you have set up animations in the .animevents file in Geppetto, an OnAnimationEvent event is called for each animation event during animation playback. You can monitor this to get notifications for animation events. The string configured for the animation event in Geppetto is held in the LmbrCentral::AnimationEvent::m_animName variable.

Get or Set the Location of an Entity in the World


BusAZ::TransformBus
MethodsGetWorldX, SetWorldX, GetWorldY, SetWorldY, etc.
FileTransformBus.h

The TransformBus contains many useful methods for getting or setting where in the world the entity is, such as xyz axis locations.

Manually Play Animations


BusLmbrCentral::SkinnedMeshComponentRequestBus
MethodGetCharacterInstance
FileSkinnedMeshComponent.h

To play animations manually, use the ISkeletonAnim in the character instance. To get the ISkeletonAnim from the ICharacterInstance, use ICharacterInstance::GetISkeletonAnim().

Use an EBus from Another Component


BusAZ::EntityBus
EventsOnEntityActivated, OnEntityDeactivated
FileEntityBus.h

The OnEntityActivated and OnEntityDeactivated events are called after all of an entity’s components have had their Activate() or Deactivate() function called. These events can be useful if you want your component to use an EBus that another component has already set up in its Activate() function.

Use Tick Events


BusAZ::TickBus
EventOnTick
FileTickBus.h

A tick is a unit of time generated by the component application. The OnTick event signals that the application has issued a tick and is called each frame. By default, handlers receive events based on the order in which the components are initialized, but you can override this. For more information, see Tick Bus and Components .