Instantiate AI - Animations datas overwritten by local datas

Riddick

New member
Hi,

I have a problem with animations sync when instantiate AI charactere over the network.

First, here is the procedure I followed to instantiate the AI charactere over the network:
1) instantiate AI charactere on the Master Client using PunObjectPool.Instantiate
2) Send RaiseEvent containing photoView.ID and custom data to others clients
3) When received RaiseEvent, instantiate AI charactere on others clients using PunObjectPool.Instantiate (using also photoView.ID and custom data).

At this moment, position, transform and health are synchonized nicely. Characteres move on the Master Client and also move on others Clients, but walk animation is played only on the Master Client!
I investigated and the conclusion is that datas animation (speed, move etc...) are send by MasterClient and received by clients, but on the clients, datas are constantly overwritten by UpdateAnimator() from CharactereLocomotion.

I found the following workaround to prevent datas to be overwritten by UpdateAnimator() from CharactereLocomotion:

C#:
  protected override void UpdateAnimator()
  {
      if (m_NetworkInfo != null && !m_NetworkInfo.IsLocalPlayer())
      {
          return;
      }
      .....
      .....
      .....
  }


the workaround works but I don't like to modify the asset files.
i also try to instantiate AI charactere using PhotonNetwork.Instantiate or PhotonNetwork.InstantiateRoomObject, same issue.

Screenshot of my AI charactere components.
1622214681107.png

Thanks for help !
 
Thanks for posting your steps and change. I plan on adding AI to the demo scene and I'll take a closer look at this then so for now I would go with your change.
 
I had the same issue. You can write a simple script that disables the UltimateCharacterLocomotion component on the client. This is what the NetworkCharacterLocomotionHandler does for normal characters. But you can't use it for AI as they don't use the CharacterLocomotionHandler. This way you don't have to modify any Opsive code.

Code:
    public class NetworkControlDisabler : MonoBehaviour
    {
        private INetworkInfo m_NetworkInfo;
        private UltimateCharacterLocomotion m_CharacterLocomotion;

        private void Awake()
        {
            m_CharacterLocomotion = GetComponent<UltimateCharacterLocomotion>();
            m_NetworkInfo = GetComponent<INetworkInfo>();
        }

        private void Start()
        {   
            if(!m_NetworkInfo.IsLocalPlayer())
            {
                enabled = false;
                m_CharacterLocomotion.enabled = false;
            }
        }
    }
 
Top