my input values ​​sync late

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.

my input values ​​sync late

JuanELG
2020-05-05 01:54:16

hi, i have a few questions about syncing my input values.

well, I check my input values ​​in the "Update" method and depending on the bool value that is returned to me I do a certain action, and when I send the bool values ​​to the clients so that they update my intances I change a variable that only they have and it continues checking the input in the remote update too.

The problem I have is that when I send the values ​​in the rpc it changes correctly to true but since the update method change them the remote cannot execute the jump action since it changes back to false before the action is executed.

In addition to solving the problem, I would like to know what is the best way to send and update these inputs in remote instances, knowing that they are updated with the update method. I have tried to do it with serialize view, rpc and raise event, but with all these the same thing happens

Also, I only send these values ​​when they change because when I update them with the "update" method so as not to overload the network, I only send them when they change.

Thank you very much for the help

Comments

hannahmontanna
2021-06-29 02:15:09

@JuanELG;d-16052 wrote:

hi, i have a few questions about syncing my input values.

well, I check my input values ​​in the "Update" method and depending on the bool value that is returned to me I do a certain action, and when I send the bool values ​​to the clients so that they update my intances I change a variable that only they have and it continues checking the input in the remote update too.

The problem I have is that when I send the values ​​in the rpc it changes correctly to true but since the update method change them the remote cannot execute the jump action since it changes back to false before the action is executed.

In addition to solving the problem, I would like to know what is the best way to send and update these inputs in remote instances, knowing that they are updated with the update method. I have tried to do it with serialize view, rpc and raise event, but with all these the same thing happens

Also, I only send these values ​​when they change because when I update them with the "update" method so as not to overload the network, I only send them when they change.

Thank you very much for the help

this is interesting, but i think you are appraoching pun from a difficult perspective.

Pun can do this, but i would suggest allowing players to input their inputs locally, and have the physics play out as they do, but then you sync players transforms.position/rotation (and lots, LOTTTTS more tricky bit trick thingies where the real meat and potaotoes of netcode lives ) to syhncrhonize movement, bullets, raycasts, hits, damage, death all taht. It's not just take inputs and then what? simulate your inputs on teh remote clinetn before finding out what you did? With neither client having real authority? (even witha server, do you really have authory? is it worth it?)

i can go on and on about this, and there are a lot of things that claim to do things, but really, its like, do they? and if they do, does it matter? that being said, fusion i believe does this to a degree.

Tobias
2021-06-29 09:07:36

PUN was not built to sync input and simulate the world with that. It lacks a tick based engine and state is distributed...

You can use PUN 2 to apply state to objects you control locally. Then send their positions and other values to everyone else to update a remote proxy.
Alternatively, Fusion is meant to sync input (for objects a player has input auth about) and then the simulation is done on the server (which then sends the state to everyone).

We can explain how to use Fusion but it's out of the scope here to explain how input sync works exactly. I don't know if you want to implement this yourself or just use it...

Back to top