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! Your search result can be found below. Plus, we offer support via 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.

Jittery player movement

Moomit
2021-08-06 16:57:19

I coded a simple method to sync player movement in Unity using Photon Pun2.The problem is when the player moves,the other player sees him moving very jittery.I found out its caused by the code i implemented,but i havent found any good soulution to fix it.

Player Code (the movements sync part):

Comments

Pablo77
2021-08-07 14:02:01

Use Lerp Like this:
You can change 0.1f as you wish.

Moomit
2021-08-07 15:30:12

@Pablo77 wrote: »

Use Lerp Like this:
You can change 0.1f as you wish.

transform.position = Vector3.Lerp(transform.position, latestPos, 0.1f);

So i should create a int or vector for latestPos?

Pablo77
2021-08-07 17:03:53

@Moomit wrote: »

@Pablo77 wrote: »

Use Lerp Like this:

You can change 0.1f as you wish.

transform.position = Vector3.Lerp(transform.position, latestPos, 0.1f);

So i should create a int or vector for latestPos?

latestPos is Recieved Data From Stream. Its Vector3.

Moomit
2021-08-07 18:36:55

@Pablo77 wrote: »

@Moomit wrote: »

@Pablo77 wrote: »

Use Lerp Like this:

You can change 0.1f as you wish.

transform.position = Vector3.Lerp(transform.position, latestPos, 0.1f);

So i should create a int or vector for latestPos?

latestPos is Recieved Data From Stream. Its Vector3.

When i tried to create like a private Vector3 latestPos

then create the function

and then adding it to the (stream.IsReading)
like latestPos = (Vector3)stream.ReceiveNext();

I am kinda confused how the syncing works

Pablo77
2021-08-07 19:27:59

it looks like it needs to work.now what's the error?

Moomit
2021-08-07 21:58:15

@Pablo77 wrote: »

it looks like it needs to work.now what's the error?

There is no error actually,the problem is that the smooth movement and this segment:

make the other player move very jittery. I tried to find a solution to fix this but had no luck

Pablo77
2021-08-08 08:00:40

@Moomit wrote: »

@Pablo77 wrote: »

it looks like it needs to work.now what's the error?

There is no error actually,the problem is that the smooth movement and this segment:

make the other player move very jittery. I tried to find a solution to fix this but had no luck

Honestly photon is little problem for really smooth transform. Maybe you can try Smooth Sync (Paid Asset). But this code works fine on me

Dogu
2023-01-19 11:36:09

I am using Photon Rigidbody View and OnPhotonSerializeView together. The output is really great like i cannot understand the delay or any jittering.

Back to top