Open 3D Engine EMotionFX Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
EMotionFX::MotionEvent Class Reference

A description of an event that happens at a given time in a motion. More...

#include <MotionEvent.h>

Inherits EMotionFX::Event.

Public Member Functions

 MotionEvent (float timeValue, EventDataPtr &&data)
 
 MotionEvent (float startTimeValue, float endTimeValue, EventDataPtr &&data)
 
 MotionEvent (float timeValue, EventDataSet &&datas)
 
 MotionEvent (float startTimeValue, float endTimeValue, EventDataSet &&datas)
 
void SetStartTime (float timeValue)
 
void SetEndTime (float timeValue)
 
float GetStartTime () const
 
float GetEndTime () const
 
bool GetIsTickEvent () const
 
void ConvertToTickEvent ()
 
bool GetIsSyncEvent () const
 
void SetIsSyncEvent (bool newValue)
 
size_t HashForSyncing (bool isMirror) const
 
- Public Member Functions inherited from EMotionFX::Event
 AZ_RTTI (Event, "{67549E9F-8E3F-4336-BDB8-716AFCBD4985}")
 
 Event (EventDataPtr &&data)
 
 Event (EventDataSet &&datas)
 
const EventDataSet & GetEventDatas () const
 
EventDataSet & GetEventDatas ()
 
void AppendEventData (EventDataPtr &&newData)
 
void RemoveEventData (size_t index)
 
void SetEventData (size_t index, EventDataPtr &&newData)
 
void InsertEventData (size_t index, EventDataPtr &&newData)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
- Static Public Member Functions inherited from EMotionFX::Event
static void Reflect (AZ::ReflectContext *context)
 

Additional Inherited Members

- Protected Attributes inherited from EMotionFX::Event
EventDataSet m_eventDatas
 

Detailed Description

A description of an event that happens at a given time in a motion.

A MotionEvent could be a footstep sound that needs to be played, or a particle system that needs to be spawened or a script that needs to be executed. Motion events are completely generic, which means EMotion FX does not handle the events for you. It is up to you how you handle the events. Also we do not specify any set of available events.

Each MotionEvent has a list of EventData instances that are attached to the event. The EventData list is used by an Event Handler to perform the required actions.

All motion events are stored in a motion event table. This table contains the event data for the event types and parameters, which can be shared between events. This will mean if you have 100 events that contain the strings "SOUND" and "Footstep.wav", those strings will only be stored in memory once.

To manually add motion events to a motion, do something like this:

motion->GetEventTable().AddEvent(0.0f, GetEMotionFX().GetEventManager()->FindOrCreateEventData<SoundEvent>("Footstep.wav"));
motion->GetEventTable().AddEvent(3.0f, GetEMotionFX().GetEventManager()->FindOrCreateEventData<ScriptEvent>("OpenDoor.script"));
motion->GetEventTable().AddEvent(7.0f, GetEMotionFX().GetEventManager()->FindOrCreateEventData<SoundEvent>("Footstep.wav"));

To listen to motion events, connect to the ActorNotificationBus, and implement OnMotionEvent().

Constructor & Destructor Documentation

◆ MotionEvent() [1/4]

EMotionFX::MotionEvent::MotionEvent ( float  timeValue,
EventDataPtr &&  data 
)

Creates a tick event

Parameters
timeValueThe time value, in seconds, when the motion event should occur.
dataThe values to emit when the event is triggered

◆ MotionEvent() [2/4]

EMotionFX::MotionEvent::MotionEvent ( float  startTimeValue,
float  endTimeValue,
EventDataPtr &&  data 
)

Creates a ranged event

Parameters
startTimeValueThe start time value, in seconds, when the motion event should start.
endTimeValueThe end time value, in seconds, when the motion event should end. When this is equal to the start time value we won't trigger an end event, but only a start event at the specified time.
dataThe values to emit when the event is triggered

◆ MotionEvent() [3/4]

EMotionFX::MotionEvent::MotionEvent ( float  timeValue,
EventDataSet &&  datas 
)

Creates a tick event

Parameters
timeValueThe time value, in seconds, when the motion event should occur.
datasThe list of values to emit when the event is triggered

◆ MotionEvent() [4/4]

EMotionFX::MotionEvent::MotionEvent ( float  startTimeValue,
float  endTimeValue,
EventDataSet &&  datas 
)

Creates a ranged event

Parameters
startTimeValueThe start time value, in seconds, when the motion event should start.
endTimeValueThe end time value, in seconds, when the motion event should end. When this is equal to the start time value we won't trigger an end event, but only a start event at the specified time.
dataThe list of values to emit when the event is triggered

Member Function Documentation

◆ ConvertToTickEvent()

void EMotionFX::MotionEvent::ConvertToTickEvent ( )

Convert this event into a tick event. This makes the end time equal to the start time.

◆ GetEndTime()

float EMotionFX::MotionEvent::GetEndTime ( ) const
inline

Get the end time value of this event, which is when it should stop.

Returns
The end time, in seconds, on which the event should be stop.

◆ GetIsSyncEvent()

bool EMotionFX::MotionEvent::GetIsSyncEvent ( ) const
inline

Check if this event is a sync event.

The Sync track of a motion can only contain events where GetIsSyncEvent() is true.

◆ GetIsTickEvent()

bool EMotionFX::MotionEvent::GetIsTickEvent ( ) const

Check whether this is a tick event or not. It is a tick event when both start and end time are equal.

Returns
Returns true when start and end time are equal, otherwise false is returned.

◆ GetStartTime()

float EMotionFX::MotionEvent::GetStartTime ( ) const
inline

Get the start time value of this event, which is when it should be executed.

Returns
The start time, in seconds, on which the event should be executed/processed.

◆ SetEndTime()

void EMotionFX::MotionEvent::SetEndTime ( float  timeValue)

Set the end time value of the event, which is when the event should be processed.

Parameters
timeValueThe time on which the event shall be processed, in seconds.

◆ SetIsSyncEvent()

void EMotionFX::MotionEvent::SetIsSyncEvent ( bool  newValue)

Set if this event is a sync event.

◆ SetStartTime()

void EMotionFX::MotionEvent::SetStartTime ( float  timeValue)

Set the start time value of the event, which is when the event should be processed.

Parameters
timeValueThe time on which the event shall be processed, in seconds.

The documentation for this class was generated from the following file: