AbilityIndex not synched

Hi,

I created my own ability to ride a bird (corresponds to the ride/rideable ability). The only issue I am facing is that the ability is not started on the remote client (right character), so the ability index is not set (which I am using for the animation). I am not using the mount / dismount events.

How can I ensure the ability is started on the remote client?

Regards, Christian

Bildschirmfoto 2020-12-16 um 11.51.17.jpg
 

Justin

Administrator
Staff member
The ability should be synced when PunCharacter.OnAbilityActiveRPC is called. Is that RPC called? If not, are you able to repro it within the demo scene?
 
I have cleaned up some code. Now I have the following effect. The RPC is always called. It calls the TryStartAbility which will always return false. The first time I start the ability, the ability is not started on the remote client. But after stopping and starting the ability again, the ability is started also on the remote client.
 
I found the issue, but I don't know what it means. The PunAnimatorMonitor sets the m_SnappedAbilityIndex initially to 0 (idle state). Now I set the ability index to 500 (fly state), but the if statement below (in the OnPhotonSerializeView) is false. So the ability index on the client is not changed. If I stop the ability, the ability index is changed to 0, and the if statement is true. Then the m_SnappedAbilityIndex = -1 allows to switch to the fly ability the next time.

Code:
 if (m_SnappedAbilityIndex == -1 || abilityIndex == m_SnappedAbilityIndex) {
          SetAbilityIndexParameter(abilityIndex);
           m_SnappedAbilityIndex = -1;
           }
 
You can reproduce the problem on the demo scene:
1.) Start the scene in the editor and a build
2.) Enable PunAnimatorMonitor logging for the remote character in the editor
3.) Move the remote character
4.) the first ability index change in the editor is not logged
 

Justin

Administrator
Staff member
Try changing that block to:

Code:
                    if (m_SnappedAbilityIndex == 0 || abilityIndex == m_SnappedAbilityIndex) {
                        SetAbilityIndexParameter(abilityIndex);
                        m_SnappedAbilityIndex = 0;
                    }

You'll also need to change the default value of the snapped ability index:

Code:
        private int m_SnappedAbilityIndex;
 
Top