How to synchronize animations without using parameters and transitions

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to synchronize animations without using parameters and transitions

matreusz4
2021-09-21 10:39:54

Hello. In my game I have really lots of animations. I found it better and easier for me to use animator.Play() or animator.CrossFade() in script instead of doing lot of trasintions and parameters. But so far as I noticed from tutorials, I can synchronize animations only by setting an parameter to synchronize, if I want to use Photon Animation View.

Of course, I have parameters to decide when to play the animations, but these are things like "whether he presses 'W' and the left shift" than "whether is running".I just don't have the parameters set in the animator.

So, do I have to rebuild my code and make animations play by parameters or there is any other solution? Each player object has a ChangeAnimationState () method. Couldn't I pass information from it describing the state of the current player to other players?

Comments

Tobias
2021-09-22 09:21:47

You can do either way. The PhotonAnimatorView was written to sync animations based on mechanim state. You can easily skip that and instead just send where the character moves to play some animation locally.

Due to lag and variance, neither approach is fully in sync.

matreusz4
2021-09-22 10:37:26

Tobias 2021-09-22T09:21:47+00:00

You can do either way. The PhotonAnimatorView was written to sync animations based on mechanim state. You can easily skip that and instead just send where the character moves to play some animation locally.

Due to lag and variance, neither approach is fully in sync.

Are there any other approaches? Im creating football game, so the most important for me will be sync position of the ball, I guess. But it's controlled by various animations, so they should also be precise.

So basiccaly, you talking about sending information from player script to every player's PhotonAnimatorView script? Sorry Im new in photon and for now I have little knowledge how it works

Tobias
2021-09-22 14:53:48

Sorry, PUN does not have the underpinning to solve this problem on it's own.

You might want to take a look at Fusion, which has a tick based system and authoritative server/host. It gives you more precision and it can definitely solve the case (but I can't say at the moment, if it's an out of the box solution without work required on your end).

The only option where one of our SDKs solves the physics problems for you, is to use Quantum. This is however not a free option, so likely not applicable to a hobby project.

matreusz4
2021-09-22 18:58:20

Tobias 2021-09-22T14:53:48+00:00

Sorry, PUN does not have the underpinning to solve this problem on it's own.

You might want to take a look at Fusion, which has a tick based system and authoritative server/host. It gives you more precision and it can definitely solve the case (but I can't say at the moment, if it's an out of the box solution without work required on your end).

The only option where one of our SDKs solves the physics problems for you, is to use Quantum. This is however not a free option, so likely not applicable to a hobby project.

Could you explain to me why I need something to solve physics problems? Couldn't it work in such a way that the physics of the ball is calculated at the client who does something with it, and its position is communicated by Photon Transform View to others?

Also, could you explain to me what exactly do to "send where the character moves to play some animation locally", because I dont know what do you mean exactly as for the practical implementation of this

It started out as a hobby project, but I believe I could make this game available to a larger community at some point, because it is already better played than some similar games. So for now, as part of the testing the game, I prefer free solutions, but I do not exclude paid ones.

matreusz4
2021-09-22 23:05:21

Tobias 2021-09-22T14:53:48+00:00

Sorry, PUN does not have the underpinning to solve this problem on it's own.

You might want to take a look at Fusion, which has a tick based system and authoritative server/host. It gives you more precision and it can definitely solve the case (but I can't say at the moment, if it's an out of the box solution without work required on your end).

The only option where one of our SDKs solves the physics problems for you, is to use Quantum. This is however not a free option, so likely not applicable to a hobby project.

Could you explain to me why exactly do I need to solve physics problem while syncing multiplayer in my game? Couldn't the physics of the ball be calculated by the client touching the ball and the position of the ball communicated to other users using the Photon Transform View Classic?

Also, could you explain to me what exactly do to "send where the character moves to play some animation locally", because I dont know what do you mean exactly as for the practical implementation of this

It started out as a hobby project, but I believe I could make this game available to a larger community at some point, because it is already better played than some similar games. So for now, as part of the testing the game, I prefer free solutions, but I do not exclude paid ones.

Tobias
2021-09-23 09:27:57

Fusion will have a similar pricing to PUN 2 and you can actually give it a go anytime for free.

Could you explain to me why exactly do I need to solve physics problem while syncing multiplayer in my game?

Actually, no.

This is part of the point I meant to make. Read the articles from Gaffer On Games if you'd need to implement this in PUN 2.

Yes, the player who touches the ball can calculate the physics for it. The player who was touching the ball last, may not have the same view of the world, however. So it either stops sending updates because it thinks someone else is now responsible (but that client didn't simulate this far yet) or it continues to send updates, because it doesn't know yet, someone else touched the ball. What if two players collided and the ball is in between?

This turns into a lot of problems which can not be explained here quickly.

About the animations: In this approach, you only send movement / position updates to everyone else. When those arrive for remote players, your code checks from where to where the character moved and play some suitable animation. The animation will not be in sync with the remote player, of course but it's "cheap" to do.

About the project: Sounds really cool, you are considering to release the game! Always exciting when a hobby project turns into something playable that could be published!

I think you reached the end of the road with PUN and have to decide if you implement some sync algorithm as explained by Gaffer on Games or you experiment with Fusion.

matreusz4
2021-11-01 11:47:45

Tobias 2021-09-23T09:27:57+00:00

Fusion will have a similar pricing to PUN 2 and you can actually give it a go anytime for free.

Could you explain to me why exactly do I need to solve physics problem while syncing multiplayer in my game?

Actually, no.

This is part of the point I meant to make. Read the articles from Gaffer On Games if you'd need to implement this in PUN 2.

Yes, the player who touches the ball can calculate the physics for it. The player who was touching the ball last, may not have the same view of the world, however. So it either stops sending updates because it thinks someone else is now responsible (but that client didn't simulate this far yet) or it continues to send updates, because it doesn't know yet, someone else touched the ball. What if two players collided and the ball is in between?

This turns into a lot of problems which can not be explained here quickly.

About the animations: In this approach, you only send movement / position updates to everyone else. When those arrive for remote players, your code checks from where to where the character moved and play some suitable animation. The animation will not be in sync with the remote player, of course but it's "cheap" to do.

About the project: Sounds really cool, you are considering to release the game! Always exciting when a hobby project turns into something playable that could be published!

I think you reached the end of the road with PUN and have to decide if you implement some sync algorithm as explained by Gaffer on Games or you experiment with Fusion.

Hello, it's me again.

After you said it couldn't be done with PUN2, I had to check it out for myself. As I understood from previous comments, photon does not support physics sync, but I found there is a "photon rigidbody view" so I implemented it.

Please let me know that I have a good understanding of the problem:

I can sync phycis with PUN2 BUT I have no way of setting it up so that the players can smoothly influence the ball as I have to transfer the OWNING of the ball between the players. And when I change ball owner, it always happens with some delay which does not match the animations and movements that play instantly when the player presses a button. If I understand correctly then there is no other solution, it cannot be set that every player will be the ball owner, is that true? It is also impossible to speed up the transfer of ownership?

Currently, it works in such a way that it is impossible to kick the ball with the first touch. Ball ownership is transferred after a short latency. For now, I would just like to test how it is to play it on multiplayer and would be happy if it could be set so that the player can kick the ball on the first touch and the rest of the players will see the kick after a short delay, as a compromise.

@editI I just added a system that changes the owner of the ball to the nearest player. This makes it possible to play, but I know that it is still a poor solution. It does not work fast and precisely enough, and each change of owner is associated with a strange jump of the ball.

Besides, after I found out why exactly pun2 works badly in this case, I'm curious how Quantum or Fusion works different when it comes to synchronizing physics between players and allowing them to influence the object. Is there no transfer of ownership of the object there or does it just work better somehow? Also, Fusion is currently in beta, I am right? And speaking of quantum, how is it with payment, there is no cheaper option than $ 1000 for 500 CCU?

I would be grateful for further help with the project.

Btw this is my game we talking about: https://www.youtube.com/watch?v=kOsN1Y8Oe50

Back to top