PUN 2 Network Transform View Jittery Movement

Hi,

I have been recently porting my project from PUN 1 to PUN 2. So naturally I used the Network Transform View that comes with PUN 2 (as I used it in 1 and it was pretty good).

In any case, I just tested with someone else over the internet (instead of my local tests). The movement was pretty jittery and laggy. Now PUN 2 doesn't come with any options to set like PUN 1. I read another post a month ago or so that talks about this and it was mentioned that Rigidbody View would fix this.

The issue with this is that while I do have a Rigidbody on the object, I am not using it for movement but rather for collisions only. I am using Unity's NavMeshAgent for movement so if even I tried to use Rigidbody, given it is based on velocity it won't sync anything.

Would my only option now be using the Streaming method? That or of course go back to PUN 1?

Thanks

Best Answer

Answers

  • Hi @Vallar,

    the PhotonTransformView component worked fine in our internal tests, but we receive more and more (negative) feedback about it, so that we have started to look for another (and better) solution. Unfortunately I can't give you any ETA about the new version. In the meantime you have different possibilities:
    • Simply wait for the new version.
    • Update the PhotonTransformView component from PUN Classic to make it compatible with PUN 2.
    • Try using the PhotonRigidbodyView component. I know you don't use it for movement, but the Rigidbody component relies on the Transform component and its data as far as I know. Means that you can try to use the PhotonRigidbodyView component although you don't use the Rigidbody itself (at least not for movement). When using it, make sure to not use its Synchronization Options (velocity and angularVelocity).
    • As you propsed: going back to PUN Classic, but I think this is not necessary.
  • VallarVallar
    edited October 9

    Hi @Vallar,

    the PhotonTransformView component worked fine in our internal tests, but we receive more and more (negative) feedback about it, so that we have started to look for another (and better) solution. Unfortunately I can't give you any ETA about the new version. In the meantime you have different possibilities:

    • Simply wait for the new version.
    • Update the PhotonTransformView component from PUN Classic to make it compatible with PUN 2.
    • Try using the PhotonRigidbodyView component. I know you don't use it for movement, but the Rigidbody component relies on the Transform component and its data as far as I know. Means that you can try to use the PhotonRigidbodyView component although you don't use the Rigidbody itself (at least not for movement). When using it, make sure to not use its Synchronization Options (velocity and angularVelocity).
    • As you propsed: going back to PUN Classic, but I think this is not necessary.


    If I use the Rigidbody View and ignore the Synchronization Options (velocity and angular velocity) will it sync Rotation of a child mesh (has no Rigidbody)? Or will I need a similar component on the child mesh?

    Also if this works in the interim then I don't mind waiting for an update with the new component.
  • If I use the Rigidbody View and ignore the Synchronization Options (velocity and angular velocity) will it sync Rotation of a child mesh (has no Rigidbody)? Or will I need a similar component on the child mesh?


    Depends on: if the child object doesn't rotate on its own, it's enough to only attach a View component to the parent object. If the child object however rotates on its own and independently from the parent object, you would have to synchronize this separately. I guess this can be done by adding a View component the child object as well and let the parent's PhotonView component observe it.
  • VallarVallar
    edited October 11


    Depends on: if the child object doesn't rotate on its own, it's enough to only attach a View component to the parent object. If the child object however rotates on its own and independently from the parent object, you would have to synchronize this separately. I guess this can be done by adding a View component the child object as well and let the parent's PhotonView component observe it.

    Right now the child rotates on its own (controlled by a script on the parent). The child (at the moment) has both a Photon View and a Transform View. The Photon View is observing the Transform View.

    If I am understanding what you said correctly, I would swap the Transform View on the parent with the Rigidbody View. Then leave the child with both the Photon View and the Transform View, except the child doesn't monitor its own Transform View, the parent does, correct?

    Also side note, I may have found a bug in PUN 2, I can't drag the elements observed by a PhotonView up and down for some reason. I have the icon on the left side of the components and it looks like I can drag (like normal UI similar elements). However when I drag, nothing happens. So now to have the Animator as the last component being observed, I have to remove it and re-add it after adding the new observed view.
  • I just noticed, that it is not working the way I thought it would...

    Your approach (having a PhotonView and a View component on both the parent and the child object) might work as well. In this case, each PhotonView component should observe the View component attached to the same object.

    Another solution would be, to implement a custom OnPhotonSerializeView solution. This one would be observed by the PhotonView component of the parent and can synchronize the necessary values of both the parent and the child object(s).
  • VallarVallar
    edited October 11

    I just noticed, that it is not working the way I thought it would...

    Your approach (having a PhotonView and a View component on both the parent and the child object) might work as well. In this case, each PhotonView component should observe the View component attached to the same object.

    Another solution would be, to implement a custom OnPhotonSerializeView solution. This one would be observed by the PhotonView component of the parent and can synchronize the necessary values of both the parent and the child object(s).

    May I ask if there are any downsides to what I am doing and what you are proposing? Well aside from the obvious problem with the current Transform View of course.
  • The difference is the number of calls: each PhotonView has to call OnPhotonSerializeView on each component. This might end up in bad performance, if there are a lot of calls (i.e. older mobile phones which don't have that much computational power). But it doesn't have to. This more or less is just a worst-case scenario.

    I see, thank you very much, this definitely makes sense. Again, @Christian_Simon your support and answers are impressive :) I'll mark your response as answered to close it down and save you some work.

    Thanks again!
Sign In or Register to comment.