Search Unity

Animation parameter won't set

Discussion in 'Animation' started by gbison, Feb 12, 2018.

  1. gbison

    gbison

    Joined:
    Feb 2, 2017
    Posts:
    5
    Hello,

    This is my first actual post on the unity boards and I have researched this problem for days and I have beat my head on the keyboard so much trying to figure it out myself; at this point, I feel like I'm wasting my time if I don't ask for help.

    What I'm trying to do is seemingly vary simple, yet has been the most complicated task yet because apparently my brain has ceased to function. I am trying to set a bool parameter that changes my animation state from a standard idle to holding a gun(hasweapon). I have literally built an entire 3rd person networked infrastructure here that functions, yet I cannot get this bool to set for the appropriate client across the network .

    So here's the scenario, I have a weapon item in my scene and when the player collides with it, it picks up the weapon, adds it to their inventory, then sets the animation state and is ready to fire. Now as long as I stay in the unity editor and am the client running the server (host) everything works great. Now when I start up multiple clients everything works great except for the shooting animation, when the player hits the weapon for pickup , the hasweapon bool is only set on the host client . Any one else sees the player packing the gun at his side (standard idle with gun attached now). The hasweapon bool is never set under the obtaining client. I have tried everything, command attributes, rpc commands, standard non networking style, nothing i do sets this parameter.

    I put islocalplayer Checks on everything and this stopped the animation from setting on the host but still never sets on other clients. I have to be failing completely here somehow, but I'm so frustrated at this Im at a loss.

    Any help would be greatly appreciated.

    Bryan
     
    Last edited: Feb 13, 2018
  2. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
  3. gbison

    gbison

    Joined:
    Feb 2, 2017
    Posts:
    5
    I have read through the unity docs multiple times. What I also don't understand is why the network animator is not automatically sending this if I check the box(I even set it through code). I mean its working fine with player movement for walking, running, jumping and such, it transmitted those and I never had to do a thing other than change the parameter value, same thing I am doing with this one. Its almost like it has a limit on how many it can update at once (does it?).

    Furthermore, I noticed something last night I did not understand. Can islocalplayer only be called under certain context or scope? I have looked through the documents and cannot find this stated, yet I seem to find that it is true. You see, it appears that the game thinks there's only one local client even if several players are connected, if I'm not testing for this variable in a unity defined callback or function it continually returns false - even on the player I'm controlling.

    So I setup a test in a new project to validate this, I setup some GUI buttons, such that when I press them it will give me the results of the islocalplayer and isserver properties through custom methods. I then setup a toggle function where by using a variable (bool) as a flag to turn calling islocalplayer off and on from the update function while the game is running. When I press the button , islocalplayer is ALWAYS false, yet when I toggle the bool flag i set in the update function islocalplayer is ALWAYS true.

    I'm going to create a simple project, throw two characters onto a plane and setup triggers all over the plane that will trigger animation changes via the animator parameters - I feel like something is bugged.