• 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
1
Question by initialsHL · Oct 26, 2012 at 09:34 AM · networkserverrpcclientping

client to client ping - NAT punchthrough

Hi, is there any way to get client A to client B ping when they are connected to the same server?

I need a way to get the direct ping from client A to client B, without going through the server.

Can client A get the NetworkPlayer of client B, and use GetAveragePing(client B)?

Or is Ping(client B) the only way? Because I believe client A is able to join client B if client B hosts a server, but client A is unable to use Ping(client B). T$$anonymous$$s could be because when joining client B (server), NAT punchthrough is used, and when using Ping(), there is no NAT punchthrough.

Can I use RPC call from client A to client B? Does the RPC go directly from A to B, or does it go from A to MasterServer / Server to B? What is the real route?

Any ideas? Thanks for help!

- Edit: (Sorry, I'll be more specific to my problem)

Here is the problem I am having: (in steps)

1) A hosts a server.

2) B is able to join A with NAT punchthrough.

3) A shuts down the server.

4) A joins server C.

5) B joins server C.

6) B cannot Ping(A.ipAddress) in server C, because A does not have a public IP and A is be$$anonymous$$nd a NAT.

How can I make B ping A directly when they are both on server C?

Or is it correct for B to do Ping(A.externalIP) in such a situation, w$$anonymous$$ch will give the proper ping value from B to A?

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
2
Best Answer

Answer by Fattie · Oct 26, 2012 at 09:41 AM

Please note - it turns out that t$$anonymous$$s answer is not of much value for Initials actual question, but has some general info.

PRIME has included some extremely important info in $$anonymous$$s critical comments below. Hope it helps someone in the arc$$anonymous$$ved future :O


Well there is only one (1) way to do any networking in Unity!

Simply use the RPC call

http://answers.unity3d.com/questions/332027/call-a-rpc-on-all-clients-at-the-same-time.html

pls vote that answer up if useful :)

When you say "server" there is a confusion:

Say four iPads are playing your game.

firstly you could mean the "boss" iPad w$$anonymous$$ch controls the others. If so, I strongly recommend you DO go via the "boss" iPad, but you don't have to.

(Let me put it t$$anonymous$$s way. For any real world networked gaming, the "boss" controls everyt$$anonymous$$ng. Sure, as a technical demo, you can send a ping between any pair.)

secondly you could mean "a server on the internet", like SmartFox or whatever.

There is absolutely no obligation at all to use a "a server on the internet" for multidevice gaming.

(Personally, I hate it - I only like MP games that allow ordinary "local networking" with your buddies in the room.)

If you do mean "a server on the internet" (A) there is utterly no reason to even use a "a server on the internet", and (B) if you are using a "a server on the internet", yes it is still possible and the norm to talk directly among the iPads, you don't go via the "server on the internet".

Again you just use RPC

that's the SECOND VERSION of RPC on the manual page...

for networking in Unity.

Here is the manual page

http://docs.unity3d.com/Documentation/ScriptReference/NetworkView.RPC.html

Comment
Add comment · Show 21 · 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 initialsHL · Oct 26, 2012 at 09:48 AM 0
Share
avatar image Fattie · Oct 26, 2012 at 09:53 AM 0
Share
avatar image initialsHL · Oct 26, 2012 at 09:54 AM 0
Share
avatar image Fattie · Oct 26, 2012 at 12:03 PM 0
Share
avatar image initialsHL · Oct 26, 2012 at 12:11 PM 0
Share
Show more comments

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

11 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

Related Questions

RPC is called but it doesn't destroy some GameObject instances 1 Answer

Spawning Clients 1 Answer

RPC Call Mix Up Issues 0 Answers

Get RPC senders ID, or IP? 1 Answer

Networking RPC calls never sent to other clients 1 Answer


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