• 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 /
  • Help Room /
avatar image
0
Question by eitanwass · Aug 04, 2016 at 05:54 PM · animationmultiplayerphotonmovetowardsclick to move

Smoothing movement in multiplayer with click and move photon PLS HELP.

Hello!

I'm working on a rts-like multiplayer project and i'm using point to move to move my character. I achieved the connection between the network including the movement and rotation and animation in the following way:

 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
         if (stream.isWriting) {
             stream.SendNext (transform.position);
             stream.SendNext (transform.rotation);
             stream.SendNext (PointToGo);
             stream.SendNext (Anim.GetBool("isRunning"));
             stream.SendNext (Anim.GetBool("isIdle"));
         } else {
             transform.position = (Vector3)stream.ReceiveNext ();
             transform.rotation = (Quaternion)stream.ReceiveNext ();
             PointToGo = (Vector3)stream.ReceiveNext ();
             Anim.SetBool ("isRunning", (bool)stream.ReceiveNext());
             Anim.SetBool ("isIdle", (bool)stream.ReceiveNext());
         }
     }

In the character i made the photonView observe this script which include more things. And yet there is some lag and the character from the other computer is jittering while walking.

So what i was wondering is if there is a way to just tell the photon view to send the "PointToGo" (the point the player clicked to make the character go there) and make the local computer interpreter that as a movement to that location with rotation and animation changing instead of sending all that data that may slow down the connection.

if you need the script for the movement on the player is:

 void Start () {
         god = GameObject.FindGameObjectWithTag ("MainCamera");
         Anim = this.GetComponent<Animator> ();
         pv = PhotonView.Get (this);
     }
 
     void Update () {
         if (pv.isMine) {
             PointToGo = god.GetComponent<PlayerMovement> ().PointToGo;
 
             if (Vector3.Distance (this.transform.position, PointToGo) > 0.1) {
                 this.transform.position = Vector3.MoveTowards (this.transform.position, PointToGo, CharacterSpeed);
                 this.transform.LookAt (PointToGo);
                 Anim.SetBool ("isRunning", true);
                 Anim.SetBool ("isIdle", false);
                 this.GetComponent<Rigidbody> ().isKinematic = false;
             } else {
                 Anim.SetBool ("isIdle", true);
                 Anim.SetBool ("isRunning", false);
                 this.GetComponent<Rigidbody> ().isKinematic = true;
             }
         }
     }

Thank you, Ethan.

Comment
Add comment · Show 1
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 ChristianSimon · Aug 16, 2016 at 08:52 AM 0
Share

This should be possible when changing the Update() function of your player's logic class where you also need to cover the case where pv.is$$anonymous$$ine == false in order to update networking players locally. This is basically the same procedure as shown above. However it can be useful to update the position and rotation once the player has reached the target position so that the game doesn't run out of sync. Even so you might check if PointToGo has changed because you don't want to send the same target position over and over again.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

146 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Syncing live animations using PUN 2 Answers

Players won't spawn with Photon Unity Network 1 Answer

Photon Sync Var 1 Answer

Help with photon being used to make a mulitplayer fps 0 Answers

Help with Photon Networking Dodge Ball Game 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