Search Unity

[SOLVED] UNET Network.Animator issues

Discussion in 'UNet' started by Rafael_SGP, Aug 19, 2016.

  1. Rafael_SGP

    Rafael_SGP

    Joined:
    Oct 27, 2014
    Posts:
    9
    How to properly use Network.Animator with Rigidibody ? I'm doing some tests with a cube and a sphere where the ball is cube son, where the animation rotate and move for all sides.

    First problem . Does not synchronize .
    on all clients , if happens to touch any other object ,unsync in each client the speed and rotation animation.

    [Solved] - Sync in all clients ,gameObject.GetComponent<Network Animator>().SetParameterAutoSend(0,true); just had put a hook function on it;

    Problem remain :some colissions do not seem to be working properly.
    .

    Second problem . NullReferenceException : Object reference not set to an instance of an object
    UnityEngine.Networking.NetworkAnimator.FixedUpdate ( ) (at C: /buildslave/unity/build/Extensions/Networking/Runtime/NetworkAnimator.cs : 100).
    I do not make the slightest idea why this is happening.

    [Solved]

    -Client's do not get the component. Just send via ClientRpc or put Network.isClient and Anim = GetComponent<Animator>();

    Third Problem.

    If you move the tab for any reason in one of the clients, the animation of this client freeze's and stay at that time unsync again.

    Following Images of Component's and Setup :

    Cube:



    Sphere :





    And the following Script on Cube:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3. using System.Collections;
    4.  
    5. public class MoveBra : NetworkBehaviour {
    6.  
    7.     #region Declaração
    8.     [SyncVar]
    9.     public Animator Anim;
    10.  
    11.     [SyncVar]
    12.     public float Timer;
    13.     #endregion
    14.  
    15.     public override void OnStartServer()
    16.     {
    17.         Anim = GetComponent <Animator>();
    18.     }
    19.  
    20.     void FixedUpdate()
    21.     {
    22.         if (!isServer)
    23.             return;
    24.  
    25.         Timer = (int)Time.time;
    26.  
    27.         if (Timer % 3 == 0)
    28.             Anim.SetBool ("Animer", true);
    29.         else
    30.             Anim.SetBool ("Animer", false);
    31.     }
    32. }
     

    Attached Files:

    Last edited: Aug 29, 2016
    dylanfrancis likes this.
  2. Rafael_SGP

    Rafael_SGP

    Joined:
    Oct 27, 2014
    Posts:
    9
    Thanks @Prommer-Games this solve part of the first problem, now it's sync in all clients , but the collision still giving some bugs.
     
  3. Rafael_SGP

    Rafael_SGP

    Joined:
    Oct 27, 2014
    Posts:
    9
    @Prommer-Games ,thanks , try it but not work. The colision detect still throwing things up.
     
  4. Flashmangagames

    Flashmangagames

    Joined:
    Apr 11, 2014
    Posts:
    3
    "Move Bra" WTF is this game?
     
    dylanfrancis and xVergilx like this.
  5. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    A game I would've probably played. :D
     
  6. joaoVictorCardoso

    joaoVictorCardoso

    Joined:
    Nov 19, 2017
    Posts:
    3
    I probably play too! thanks guys for this issue solved