How start with initial ability active?

ChristianWiele

Moderator
Staff member
Hi,

I would like my players to start in a sleeping position, using the Generic ability to play a corresponding animation. I have written a script that starts this ability on start. But I run into an issue. As the ability is started early on, the PunAnimatorMonitor snaps the animator on the remote client to this ability. After this, no ability change is applied on the remote client anymore as the m_SnappedAbilityIndex is set to the one of the Generic ability.
What is the intended way to start with an ability active, or is there a way to reset the snapping after the Generic ability has been stopped?

Thanks, Christian
 

Justin

Administrator
Staff member
There is a callback OnAnimatorSnapped which you could subscribe to and start your ability after it has been called. You'll want to unsubscribe from the event at that time as well.
 

ChristianWiele

Moderator
Staff member
I was thinking about this. Unfortunately, at start this event is triggered at least 3 times in different Start methods in my case (InventoryBase, AnimatorMonitor, UltimateCharacterLocomotion), either directly or through the OnCharacterSnapAnimator event. So, I would have to wait for the third event, but I am not sure whether this is reliable enough?
 

Justin

Administrator
Staff member
After the player spawns can you start the ability manually? By then the animator should be snapped. You could also introduce a delay using the Scheduler to start the ability after a short amount of time.
 

ChristianWiele

Moderator
Staff member
I will listen to the OnAnimatorSnapped event, taking the third event as final. This works so far. But overall it would be helpful, when the player is initialized completely, also in other situations. For instance, in multiplayer mode I would like to start the game / open the curtain only if all players are really ready. So, if you could add such an event in future, this would be great.
 
Top