Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by infinip · May 21, 2013 at 08:37 AM · editornetworkingperformancelag

Intense CPU usage when running networking code on Editor only

I'm trying to understand networking, so I wrote up a very rudimentary client-server interaction with RPC calls. I have an issue with running this little test on the editor, but the standalone player handles it perfectly fine.

Setup: There is only one scene, it contains a cube that can be selected and moved on a plane through mouse input, like an RTS game. The cube movement is a Vector3.Lerp from its current position to a target position that can be set.

As it stands, if I run both client and server instances with the standalone Unity player, it's fine. The client is a little choppy (I believe due to a lack of client-side prediction, correct me if I'm wrong), the server runs completely smooth, and both instances take no more than 5% CPU.

However, if I try to run either side on the Unity editor, the editor eats up an entire core and is noticeably choppier. The other side is fine as above, though if I'm running the server on the editor the client suffers even more, so I'm inclined to think it's a performance issue in the editor.

I don't think my network setup is at fault. I setup both ends to 127.0.0.1:25001, and the server reports that it receives 1 connection from 1 client, etc.

Here's my code for the cube's movement. It's the only place where I have RPC calls in the project. I've taken steps to limit execution to only where it's relevant, but I don't see any improvement.

 public class MoveUnit : MonoBehaviour {
        private Vector3 targetLocation;
 
     void Awake()
     {
         targetLocation = transform.position;
     }
     
     void Update()
     {
         if(Network.peerType == NetworkPeerType.Client)
         {
             enabled = false;
         }
         else if(Network.peerType == NetworkPeerType.Server)
         {
             transform.position = Vector3.Lerp(transform.position, targetLocation, Time.deltaTime);
         }
     }
     
     // Called by input handler sripts. Delivers a new target position for
     // this object to move towards.
     void MoveOrder(Vector3 newPosition)
     {
         if(Network.peerType == NetworkPeerType.Client)
         {
             networkView.RPC("UpdateLocationServer", RPCMode.Server, newPosition);
         }
     }
     
     // Server-side, receives a new target position for this object to
     // move towards.
     [RPC]
     void UpdateLocationServer(Vector3 newPosition)
     {
         if (Network.peerType == NetworkPeerType.Server)
         {
             targetLocation = newPosition;
         }
     }
 }

For the obvious troubleshooting: My quality setup involves VSync at every VBlank (without it even the standalone player suffers). The NetworkManager has Sendrate at 30, with logging disabled. There is no logging going on at all.

I have reimported everything once with no noticeable improvement.

I haven't downloaded any packages to Unity besides an official demo.

I don't have Unity Pro, so I can't make use of the performance profiler.

Does anything here look wrong to you? I'd appreciate any ideas on how I can troubleshoot this.

Thanks!

Edit: The problems seem to have disappeared after a reboot (not simply restarting Unity, apparently). While I'm disappointed that a bunch of system standbys would cause something like this, I'd still appreciate any tips on my setup above that can be improved.

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 Benproductions1 · May 22, 2013 at 01:44 AM 0
Share

If you want tips, go to the forums. Since this is now fixed, please close the question :)

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.

Follow this Question

Answers Answers and Comments

14 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

Related Questions

Editor incredibly slow, weird profiler output. 1 Answer

Unity Game preview lags on new laptop 1 Answer

Some questions regarding quality and performance in Unity. 1 Answer

HUGE Lag spikes in editor when playing an animation. Over 400ms GC.Collect (profiler screen included) 2 Answers

Unity crashing efter losing connection to other Unity 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