Search Unity

Custom Messages not working with animator.play()

Discussion in 'VR' started by foxvalleysoccer, Sep 29, 2017.

  1. foxvalleysoccer

    foxvalleysoccer

    Joined:
    May 11, 2015
    Posts:
    108
    The command is working on the hololens I'm wearing but its not broadcasting and running the command on the other hololens in the sharing session.

    Both are in the same sharing room and other commands are broadcasting just fine.

    Why is this command failing?



    CustomMessages.cs
    Code (CSharp):
    1.  public void SendSyncThePistonAnimation()
    2.     {
    3.         if (this.serverConnection != null && this.serverConnection.IsConnected())
    4.         {
    5.  
    6.             NetworkOutMessage msg = CreateMessage((byte)TestMessageID.SyncThePistonAnimation);
    7.  
    8.             this.serverConnection.Broadcast(
    9.                 msg,
    10.                 MessagePriority.Immediate,
    11.                 MessageReliability.ReliableOrdered,
    12.                 MessageChannel.Avatar);
    13.         }
    14.     }
    EnergyHubBase.cs

    Code (CSharp):
    1.   void Start()
    2.     {
    3.         innerEngineAnimator = innerEngineAnimation.GetComponent<Animator>();
    4.  
    5.      
    6.         CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.StopTheEngine] = this.SendStopEngine;
    7.  
    8.    
    9.         CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.SyncThePistonAnimation] = this.SyncThePistonAnimation;
    10.  
    11.     }
    12.    public void SyncThePistonAnimation(NetworkInMessage msg)
    13.     {
    14.         innerEngineAnimator.Play("New State", 0, 0);
    15.  
    16.     }
    VoiceCommands.cs
    Code (CSharp):
    1.     private void SyncThePistonAnimation()
    2.     {
    3.         CustomMessages.Instance.SendSyncThePistonAnimation();
    4.         NetworkInMessage msg = null;
    5.         TheEnergyHub.GetComponent<EnergyHubBase>().SyncThePistonAnimation(msg);
    6.  
    7.     }