Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by javivv1 · Jul 23, 2015 at 08:15 PM · unity 5movementplayerphotonlerp

Photon Network Movement Delay

Hello! First... sorry for my english, not so good!

I'm having troubles testing with player movements on Photon, imagine I open 2 windows:

On play, I instantiate a "Player", with PhotonView and a Network script with this:

 private Vector3 correctPlayerPos;
 private Quaternion correctPlayerRot;

 void Update()
     {
         if (!photonView.isMine)
         {
             transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 7);
             transform.rotation = Quaternion.Lerp(transform.rotation, this.correctPlayerRot, Time.deltaTime * 10);
         }
     }
 
     
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);
         
     }
     else
     {
         this.correctPlayerPos = (Vector3)stream.ReceiveNext();
         this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
     }
 }



This test is like a 3rd person shooter, when I move one player I can see it on the other windows moving correctly, smoothly, BUT it have a small delay on movement... just some miliseconds, but enough to malfunction...

While player 1 is running, if you take a look at 2nd window it is moving some "steps" behind. When I shoot with player 1 to an static objective, on window 1 the bullet collides with the objective, on window 2 the bullet doesn't collide, it's some "steps" behind...

What can I do? I can't find a solution, I tried to "predict" the real position adding the velocity variable to the "correctPlayerPos" unsuccessfully...

Thank you

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rbisso · Jul 23, 2015 at 11:27 PM

Did you try using the PhotonTransformView to synchronize the positions?

I would recommend doing this tutorial and analyzing their steps thoroughly before heading off on your own: https://doc.photonengine.com/zh-cn/pun/current/tutorials/rpg-movement

Also, as a heads-up, you're going to want your bullets to be instantaneous and deterministic in the way that they travel/hit to account for lag. If you have a very unforgiving system, it's going to fail often.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image javivv1 · Jul 24, 2015 at 08:05 AM 0
Share

Thank you, I will test this.

Which is the best way to do this?, imagine for example:

An online game where each player is moving a tank in 3rd view, the tank can rotate the gun and shoot a bullet in the direction where the gun is pointing.

If I start to moving the tank to the right and shot up, I can see how the bullet strikes on the enemy tank, but the other player on his screen look like the bullet goes slight to the left, on his screen I'm still not in front of him, because of the delay I am slightly to the left and the ball does not impact.

There are many games in which this works well, for example in league of legends where the movement is very fast, everyone sees enemies in the correct position. I need to understand how to make the positions of the players 100% accurate.

Or in Counter Strike, the position of the players must be 100% perfect or the game would be unplayable.

This games look smooth and the position is perfect... any idea how can I do it?

avatar image javivv1 · Jul 24, 2015 at 10:29 AM 0
Share

I've tested PhotonTransformView, the unique option working "almost" correctly is Extrapolate: Estimated speed and turn, but the visual movement is really bad...

There must be another way to do this, or $$anonymous$$$$anonymous$$ORPG games can't exist, there can't be this difference in the position of the players ...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

MultiPorposeCameraRig makes the camera float 0 Answers

player not moving over the bridge 1 Answer

photon player movement 1 Answer

Player rotation restricted even though I don't want it to be 0 Answers

Photon Player Controls Other Player 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges