Play sequence in Lua


We are currently facing an issue when trying to play component entity sequence from Lua code.

Maybe we miss something. Below the steps to reproduce :

  • Create a component entity sequence : This automatically creates a new entity with a component “Sequence”. The entity animated by the sequence got a component “SequenceAgent” automatically added to it. Note that it’s not possible to add manually either “Sequence” or “SequenceAgent” component.

  • Add a LUA script to the animated entity by sending an event to the sequence entity :

GameplayNotificationBus.Event.OnEventBegin(notificationIdToSend, self.entityId);
  • Add a LUA script component to the sequence entity and receive the event sent above and call “Play”;<br>

But it doesn’t work. I got following error :

[Error] (Script) - content/scripts/triggereventreceiversequence.lua:39: attempt to call field ‘play’ (a nil value)

Is this the correct way to play a sequence via Lua ?

Do we miss something ?

Can you please help on this?

Thanks in advance


Can someone help on this ?


Found the issue :

It’s “Play” (with caps) and not “play”. The Lua Editor IntelliSense misled me.

It’s a minor issue but it can be annoying.

For example, when you start to type “p” (without caps), the IntelliSense suggest you “Play”. But when you choose it, you have “play” instead of “Play”

Also the “Play” have to be called on the animated entity (and not on the sequence entity).

The sequence entity is provided as parameter to this function.;

“self.Properties.Recipients.Entity” here is the sequence entity.

Note that I detect another bug (beside the one on Intellisense) : Trying to set the speed play doesn’t work. Code below :

SequenceComponentRequestBus.Event.SetPlaySpeed(self.Properties.Recipients.Entity, 4);