Animator in child object of PhotonView.

Options
Hello!

How can i synchronize an animator in the child object of my player prefab (who has a photonView on it) using PhotonAnimatorView?
If i try to put the PhotonAnimView next to the photonView in the parent, it adds an animator to the parent automatically, which is not needed since the animator is in the child object.
But if if try to put the PhotonAnimatorView next to the animator component in the child, then i automatically get a photonView in the child.

Is there a way around this, or is it normal to have a photonView for each child gameobject?
Maybe i can change the code in the PhotonAnimatorView to make it work as i want?
(of course i can't just move the animator to the parent to simplify things...)

Comments

  • Kekora
    Kekora
    edited March 2017
    Options
    Hi, I had a similar problem before. The way I fixed it might not the ideal way, but it works for me..

    Leave the Animator on the child object but don't assign a Controller to it. The controller (Assets->Animators->xx) should be dragged into the Controller slot into the Animator of the parent that is next to the Photon Animator View. For me this did actually animate the character that was under the parent.

    I think the Photon Animator View must have an Animator on the same node for it to work, which is why it automatically creates an animator if not there already.

    Hopefully it's that simple for you too.
    Some related info below:

    Later on.. If you have multiple child objects (different genders or races in the same prefab..) then you will want to copy the "Avatar" from the child Animator onto the parent Animator at the time you are hiding/unhiding meshes. I did this in C# with something like..

    GameObject childnode = parentnode.transform.FindChild(loadmesh).gameObject;
    parentnode.GetComponent().avatar = childnode.GetComponent().avatar;

    Keep in mind that doing this copy may reset values on the Animator variables, so set/apply them after the copy code.



  • MagicDesign
    edited March 2017
    Options
    thanks for the quick answer!

    I tried your solution but unfortunately, it was not the good thing in my case... I just can't use an animator from the parent because a LOT of things already need it where it is on the child...

    i did however find a solution, i just tweaked the PhotonAnimatorView a little, in the Awake function there's a "this.m_PhotonView = GetComponent PhotonView ", which is why the Anim view needs to be in the same spot as the PhotonView, i just removed that and instead i set m_PhotonView with a public variable i can see in editor, where i just drag and drop the view from the parent, and it works! i also had to remove the [requireComponent(typeof PhotonView)] to prevent the PhotonAnimatorView to spawn a PhotonView next to it... and that's it.

    =D
  • Kekora
    Options
    wow ok, well i'm glad it works.