Photon Animator View - What about Triggers?

Options
wieljer
wieljer
edited January 2017 in Photon Unity Networking (PUN)
I see there is probably no way to auto pull triggers by default with this script for animation. However since the Trigger section does not have any comments on how it should be handled in this class, I'm hoping to get some idea on what to place within the trigger case. Currently I am using an RPC from the characters controller script but I feel I can better optimize and make the code more efficient by adding it to the SerializeData?
                switch (parameter.Type)
                {
                    case ParameterType.Bool:
                        stream.SendNext(this.m_Animator.GetBool(parameter.Name));
                        break;
                    case ParameterType.Float:
                        stream.SendNext(this.m_Animator.GetFloat(parameter.Name));
                        break;
                    case ParameterType.Int:
                        stream.SendNext(this.m_Animator.GetInteger(parameter.Name));
                        break;
                    case ParameterType.Trigger:

                        break;
I really love this script and I would hate to have to use a RPC for a trigger (anim property) if there is a more efficient way to use serialization within this class I would love it if someone could give me an example using it with a trigger :) !

Best Answer

«1

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @wieljer,

    Maybe you can find what you're looking for in the new Photon Animator View Triggers doc page: https://doc.photonengine.com/en/pun/current/reference/animatorviewtriggerhelp
  • wieljer
    Options
    Hi @JohnTube,

    Sadly this did not cover the type of information I am seeking. Let me try to break down my original query a little more simply. Hopefully this clarifies my question:

    How do I use Triggers with the Photon Animator View? (examples would be nice)
  • wieljer
    Options
    Hi @jeanfabre

    Yup this update did the trick, I can remove all those messy RPC conversions now! This will save me so much time thanks!

    Appreciate you jumping in and answering this one for me!
  • jeanfabre
    Options
    Hi,

    You are welcome, feel free to pm me and mention problems you posted but did not get any answers.

    Bye,

    Jean
  • wieljer
    wieljer
    edited May 2016
    Options
    @jeanfabre I updated again today, I noticed that the DemoMecanimGUI does not have these new parameters for the triggers showing :) - I went ahead and added the lines of code. Now with the Trigger showing in the GUI I also noticed that when sending the trigger it is received by my own 'received' values even though I sent it to my remote instance. All other parameters seem to be fine its just triggers ?
  • jeanfabre
    Options
    Hi,

    ok, there may be some confusion here.

    -- DemoMecanimGUI doesn't use trigger, the demo I am working on is not yet release and will use an edited version of the Animator controller that will have the jump parameter as trigger.

    -- I am not sure what ou mean by "Sending the trigger", normally you just use .SetTrigger("Trigger name") and the Photon Animator View does the rest ( if you have enabled synchronization for the parameter).

    so maybe you could detail a bit more your issue with the received values and the remote instance?

    Bye,

    Jean
  • wieljer
    wieljer
    edited May 2016
    Options
    @jeanfabre

    Thanks for the response and sorry for the confusion, I'll try to clear that up:

    -- I updated the DemoMecanimGUI script myself to include the bool value for the trigger (because I found it very useful when prototyping my project and wish to continue using it).

    -- In the PhotonAnimatorView - ParameterType.Trigger ... Animator.GetBool(parameter.Name). The DemoMecanimGUI finds this component and displays the trigger {send & receive} values (because I added the trigger to the DemoMecanimGUI).

    When the boolean is sent representing the state of the trigger, it is received by the local client sender. The DemoMecanimGUI revealed this to me, perhaps I will just wait for the next update so I can see how you have it configured :)

    Thanks!
  • jeanfabre
    Options
    HI,

    Have you refactored the Animator Controller to use a trigger instead of a boolean for its parameter?

    I'll send you this afternoon a package with the demo I am working on, so that you don't have to wait.

    Bye,

    Jean
  • wieljer
    Options
    Okay sounds great! Really appreciated
  • jeanfabre
    Options
    Hi,

    Sorry, it took longer than expected,

    Please download it below
    https://dl.dropboxusercontent.com/u/17356625/Unity/ExitGames/demoTest.unitypackage

    Be aware, this is a work in progress, so use a fresh project, dedicated for this, to not pollute your production projects.

    Let me know if you don't find what you need, but basically, it's the same as the current mecanim demo but using a trigger parameter for jumping.

    Bye,

    Jean
  • wieljer
    Options
    @jeanfabre Great thanks, I've downloaded it and will try it out tonight!
  • wieljer
    wieljer
    edited May 2016
    Options
    @jeanfabre - i tested this out and took a look at the logic behind it. Seems like it works logically but there does seem to be missed packets or perhaps updates that are sent too late. The video below you can see when jumping the trigger isn't always received on our remote instance of our-self. Once in the very beginning of the video and near the end you can see this occur. This is a really nice demo though, I have some triggers that are essential to be received in the right order before other triggers can occur so if one is missed then I'm in trouble :(

    https://youtu.be/8CUKeaK_1u8

    Perhaps we can figure this out together ! Thanks for your assistance, I will test anything you have :)
  • jeanfabre
    Options
    Hi,

    Interesting, and you haven't touched the Player Prefab?. What version of Unity are you using?

    Typically, to solve this, you need to be aware of the Unity restriction regards Triggers. since they only exists between the time you raise it and the end of the frame, it's important that the component that raise the trigger is processed before the PhotonAnimatorView ( so that it's true already). so open the Player prefab in the resource and check that the "PhotonAnimatorView" script is the last component on the stack, or that at least the "PlayerAnimatorManager" script is above the "PhotonAnimatorView" script.

    so nothing is missing regards Photon and packets, it's simply on the GameObject itself that the trigger is never caught true because set after the "PhotonAnimatorView" did it's job for that frame.

    Let me know how it goes,

    Bye,

    Jean
  • wieljer
    wieljer
    edited May 2016
    Options
    @jeanfabre I just gave it another go in a new project but have the same results from both Master and Client receiving it. I haven't touched anything really just a straight import of PUN+ and then Import package, enter my PUN ID, add scenes to build order then build the application and run two instances.

    I double checked the player prefab and the "PlayerAnimatorManager" script is above the "PhotonAnimatorView" script.

    I'm running Unity 5.3.4f1 and PUN+ 1.68 on Windows10
  • jeanfabre
    Options
    Hi,

    ok, that's not cool at all... I can't repro this, I tried on 5.3.4 P5 and the latest pun 1.68 from the asset store. Maybe this is a windows issue?! but that would be very bad if that was the case..

    one thing that you can do right now to progress while I get to the bottom of this issue.

    simply remove the PhotonAnimatorView from the prefab and add it again, and set it up to have all the parameters synched and try again. The goal is to shake the prefab component order so that it's correctly.

    Can you also check that your Script Execution order editor settings are clean from any overrides?

    http://docs.unity3d.com/Manual/class-ScriptExecution.html

    Bye,

    Jean
  • jeanfabre
    Options
    Hi,

    one more thing. In order to quickly test this, you don't need to publish, you simply run in the editor, and select the instanciated player, and watch the PhotonAnimatorView parameter change in real time as you control them, if you don't see the jump parameter being set to TRUE when you jump. no need to deploy and test with two running applications.

    Bye,

    Jean
  • wieljer
    Options
    I had some odd issues, take a gander at this video
    https://youtu.be/DNjRJP0ZX8Q
  • jeanfabre
    Options
    Hi,

    Good catch with the warning. It's fixed now, you can safely ignore this however.

    As for the problem with jumping, I can finally repro this locally, and it looks bad because even the animator Controller doesn't seems to catch the Trigger and update the parameter, while actually acknowledging the flag and executing the transition, so I'll file a bug report.

    I'll get back to you when I get a proper way of working with this. It's really odd, we already faced this when I initially started working on this, and it seems it came back with a vengeance! :)


    Bye,

    Jean




  • jeanfabre
    Options
    Hi,

    ok, I got it. It was a mix up of many small issues.

    - Now it's properly using triggers
    - Discrete and Continuous options are both supported when you want to synch triggers using PhotonAnimatorView ( it was only working with continuous)

    Please redownload from the dropbox link

    https://dl.dropboxusercontent.com/u/17356625/Unity/ExitGames/demoTest.unitypackage

    let me know if that fixed it.

    Bye,

    Jean
  • Brodyaga
    Options
    @jeanfabre,
    Triggers are not synchronized. I'm using the latest version of PUN. Component at the end.
  • jeanfabre
    Options
    Hi,

    You can confirm this is working by checking the PunBasic Demo, the jumping is done using a trigger. So publish the demos, test and if jumps appears across all instances then triggers are fine, and something isn't setup properly in your scene, animator or code.

    Let me know if you can't get anywhere with this.


    Bye,

    Jean
  • Brodyaga
    Options
    @jeanfabre, In the Demo scene jump not working. The latest version of Unity.
  • jeanfabre
    Options
    Hi,

    uhm, yes, I can repro this on 5.5. It works on 4.7, something has changed apparently. investigating.

    Bye,

    Jean
  • jeanfabre
    Options
    Hi,

    Can you switch from discrete the Continuous for the trigger serialization option in the PhotonAnimatorView. This did the trick here, but I haven't found yet why it stopped working for discrete...



    Let me know if this works for you on your end., then I can investigate further as to what changed.

    Bye,

    Jean
  • Brodyaga
    Options
    I have tried discrete and continuous. In any case, it is not working.
  • jeanfabre
    Options
    Hi

    interesting...

    can you try copying the photonanimatorView, deleting it and then pasting it as new and see if it works then ( don't forget to observe it again from the photonView)? basically what is likely happening is internally the order of execution between the component is shuffled and it not reflecting the visual order in the inspector

    Bye,

    Jean
  • Brodyaga
    Options
    And I also did, but to no avail
  • jeanfabre
    Options
    Hi,

    what version exactly of Unity do you have and what version of PUN?

    Bye,

    Jean
  • Brodyaga
    Options
    Unity 5.5.0f3. PUN 1.80