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 /
avatar image
0
Question by Dexter.Unity · Apr 02, 2014 at 06:46 PM · networkingnetworkcommunication

Which ways are available for a Unity program to communicate with other programs?

I have node.js on my computer. I was trying to communicate with Unity using Socket.io. This however seems to be very difficult because of loads of errors and bad examples in projects on github.com

I know you can request websites with the WWW class, but this is too slow if you want to update a position of an object many times a second (please correct me if I am wrong!).

So I was wandering in which ways (www, [ws://], [ipc://]) can Unity communicate with the computer or other programs outside of it's own environment?

And maybe which type of communication is already made for Node.js? (since that's the program I am using to control communications from other ip's)

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 omrikey · Apr 05, 2017 at 08:25 AM 0
Share

Hi because the answers above are from 2014 , I wonder if this answer is still relevant and updated thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by fafase · Apr 02, 2014 at 06:53 PM

www class should be fast enough, we are currently working on a project where a server update position of up to 8 objects (only 8 for now 20 coming up) and it works fine with www request. There would be a latency if you were contacting a remote server but when on the same computer the request is almost instant.

If you do not have a server set up you can probably use localhost and use the request. The other solution is just to use a classic text read/write and parser since you know where the json file is stored.

Comment
Add comment · Show 4 · 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 Dexter.Unity · Apr 02, 2014 at 07:01 PM 0
Share

Thank you for you answer! It is on the same computer indeed. How then would Unity know something changed in the text file? Constantly on every Update() read the file and check changes? Or clear the file if something has been processed (this would then defeat the purpose of being able to push data right?) ?

avatar image fafase · Apr 02, 2014 at 07:07 PM 0
Share

Well considering the other application is constantly writing over the existing file, you can have a coroutine to check for the file and see for modifications:

 void Start(){
    StartCoroutine(CheckFile());
 }
 
 IEnumerator CheckFile()
 {
     float freq = 0.5f;
     float timer = 0; // This is to lower frequency of check
     while(true){
         WWW www = new WWW(url);
         // Check for www.error
         // Parse and check for info
         while(timer < freq){ // 2Hz frequency
             timer += Time.deltaTime;
             yield return null;
         }
         timer = 0f;
         yield return null;
     }
 }
avatar image Dexter.Unity · Apr 02, 2014 at 07:25 PM 0
Share

Thank you, I will try this code! If it works you'll get the thumbs up! =)

avatar image Dexter.Unity · Apr 04, 2014 at 08:03 AM 0
Share

Hey it's working quite fast, however adding more values I am afraid it might become slow but for now it's most certainly a good solution! Thanks!

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

22 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

Related Questions

Problems with UDP data sending 1 Answer

Is there a more flexible method of sending data over network than RPC? 1 Answer

LAN NetworkTransport communication issue 1 Answer

UNet does not call OnServerReady on second connect from same machine 0 Answers

Unity Mirror Networking - can't create a server on a build game, IL2CPP Mistake 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