PUN2 Position and Animation SYNC Problem
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
PUN2 Position and Animation SYNC Problem
Newbiedev
2022-09-28 21:45:45
I am using Photon Engine 2 for the first time. I made and tested a very simple 2d game for testing purposes. The animations of the two characters are not synchronized. For example, I swing a sword with the 2nd player, but it does not swing at the same time. It shakes on the 1st player's screen after 0.5 second. So sometimes it deals damage and sometimes it doesn't. Also, the transform of the characters is out of sync. While the 2nd player's transform position x is -3 on the 2nd player's screen, the 2nd player's transform position x is around 2.5f on the 1st player's screen. Both animations and positions are out of sync. The game is also not smooth. The characters tremble when they run. I think this is the most popular multiplayer tool. How do you use it? Are there settings I don't know about? My settings:
Comments
Actually, we'd recommend using Fusion in new projects. It's state of the art, more effective and precise.
Don't use a PhotonTransformView and a PhotonRigidbodyView (3d or 2d doesn't matter) on the same object. The RigidbodyViews already sync the transform.
Using an AnimatorView has drawbacks. It will attempt to sync the triggers but that's not always possible with Unity (a timing problem). Also, it means all animations trigger via updates arriving via the internet and this doesn't always match the local view / state a client has (much more so, when physics are involved).
I would recommend writing your own "observable" script to sync which actions / input a player does. Then trigger animations based on that.
Hope that helps. Even a popular tool is just a tool. Especially for networking, these tools require some getting used to.
Tobias 2022-09-29T10:41:41+00:00
Actually, we'd recommend using Fusion in new projects. It's state of the art, more effective and precise.
Don't use a PhotonTransformView and a PhotonRigidbodyView (3d or 2d doesn't matter) on the same object. The RigidbodyViews already sync the transform.
Using an AnimatorView has drawbacks. It will attempt to sync the triggers but that's not always possible with Unity (a timing problem). Also, it means all animations trigger via updates arriving via the internet and this doesn't always match the local view / state a client has (much more so, when physics are involved).
I would recommend writing your own "observable" script to sync which actions / input a player does. Then trigger animations based on that.
Hope that helps. Even a popular tool is just a tool. Especially for networking, these tools require some getting used to.
Thank you for reply. I added Photon Fusion to my project. But this is totally different from Pun2. Are there any tutorial? For example, when players count is 2 in room, i want to start the game. I also want the maximum number of players in the room to be 2. How can I do these? PUN2 was very easy to use. But Fusion scared me.
Johan_Liebert96
2022-10-02 23:48:29
PUN2 was very easy to use. But Fusion scared me.
I actually agree with this, for someone starting with Multiplayer games and starting with photon, in my opinion fusion would not be the way to start, for someone starting with multiplayer, PUN2 is very easy to use, it also has great documents, anyways I'd suggest checking the open source games the Photon has provided with Fusion, you'll get an idea of how it works etc
Johan_Liebert96 2022-10-02T23:48:29+00:00
PUN2 was very easy to use. But Fusion scared me.
I actually agree with this, for someone starting with Multiplayer games and starting with photon, in my opinion fusion would not be the way to start, for someone starting with multiplayer, PUN2 is very easy to use, it also has great documents, anyways I'd suggest checking the open source games the Photon has provided with Fusion, you'll get an idea of how it works etc
I've looked at a few projects, but simple things are explained in such a complicated way. What I want to do is simply connect to the room, start the game when there are 2 players in the room, switch to the other scene, send string and float data to each other via RPC, players can see each other's position, movements, animations. It shouldn't be this complicated.
Johan_Liebert96
2022-10-04 22:23:42
Newbiedev 2022-10-04T08:27:39+00:00
https://forum.photonengine.com/discussion/comment/62024#Comment_62024
I've looked at a few projects, but simple things are explained in such a complicated way. What I want to do is simply connect to the room, start the game when there are 2 players in the room, switch to the other scene, send string and float data to each other via RPC, players can see each other's position, movements, animations. It shouldn't be this complicated.
Well, in that case, start with PUN2, go look at tutorials, what you want is very basic and theres tons of tutorials, that'll be the best way to start
Johan_Liebert96 2022-10-04T22:23:42+00:00
https://forum.photonengine.com/discussion/comment/62037#Comment_62037
Well, in that case, start with PUN2, go look at tutorials, what you want is very basic and theres tons of tutorials, that'll be the best way to start
PUN2 has lag and sync problem at fighting games :(
Johan_Liebert96
2022-10-05 00:24:05
Are you using PhotonSerializeView??
Have a look at this
https://doc.photonengine.com/en-us/pun/current/gameplay/lagcompensation
It shouldn't be this complicated.
Well and that is exactly the misconception. Lag is simply a given, no matter what you do. The internet is not a perfect no-loss instant connection. If you want to hide lag, things are a bit more complicated than singleplayer, because you constantly have to update state between clients.
Fusion solves a lot of those problems for you but you need to know how you can work with it, to not reverse what it does.
For fighting games, we would recommend Quantum. It's currently free to try and once you get the hang of it, doesn't require you to solve networking issues. There is a Quantum Fighting Game Demo.
Tobias 2022-10-05T16:06:42+00:00
It shouldn't be this complicated.
Well and that is exactly the misconception. Lag is simply a given, no matter what you do. The internet is not a perfect no-loss instant connection. If you want to hide lag, things are a bit more complicated than singleplayer, because you constantly have to update state between clients.
Fusion solves a lot of those problems for you but you need to know how you can work with it, to not reverse what it does.
For fighting games, we would recommend Quantum. It's currently free to try and once you get the hang of it, doesn't require you to solve networking issues. There is a Quantum Fighting Game Demo.
Fusion or Quantum for fighting games?
Quantum would be the first choice. It is not (yet) free to develop with but current available for anyone who's participating the Back to School GameJam, so you could check it out first hand. If you are developing a game professionally, it will save your studio money and is a solid bet for all platforms.
If you plan only Standalone / Consoles, Fusion should be a solid second place. Hosting matches on mobile and WebGL is not a (good) option.
Back to top