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
2
Question by Tidus-Yuna · Oct 25, 2012 at 12:48 PM · rpcnetworkview

RPC to specific clients Problem: networkView.RPC("SetPosRot", item._networkPlayer, pos, rot);

Hello,

I am making a networking game and in this game players can be in different scenes. So I want to send RPC to players who are in the same scene. First I send info of the chosen scene to all players with "networkView.RPC("SendPlayerInfo", RPCMode.All);"

In short All clients have the info of other players in a list named "ClientInfo.AllClientInfos".

And I try the following code on spawned object (player):

 void Update () 
 {
 // movement code here
 
       foreach (PlayerInfo item in ClientInfo.AllPlayerInfos)
       {
           if (item._gameType == GameType.GameType1 && item._networkPlayer != Network.player)
                   networkView.RPC("SetPosRot", item._networkPlayer, transform.position, transform.rotation.eulerAngles);
       }
 }

 [RPC]
 void SetPosRot(Vector3 pos, Vector3 rot)
 {
     transform.position = pos;
     transform.eulerAngles = rot;
 }
 

This works fine when I only have server and 1 client. But after more clients join, only server can see the changes of movements, other clients cannot see the movements. They can only see server movements and not moving spawned players of other clients.

Error messages on Client side when other client player spawned:

  1. View ID SceneID: 0 Level Prefix: 0 not found during lookup. Strange behaviour may occur

  2. Could't invoke RPC function 'SetPosRot' because the networkView 'SceneID: 0 Level Prefix: 0' doesn't exist

What I understand from this error is that client cannot find the spawned object Allocated ID and can't set its position which is not expected, because I see that it is there...

And one more thing, when I use the following code instead of sending RPC to specific clients, everything is work fine except the same error message when one of the client choose another scene (and this is an expected error, because in other scene there is no same type spawned object).

 networkView.RPC("SetPosRot", RPCMode.All, transform.position, transform.rotation.eulerAngles);


So where do I do wrong? Any help appreciated.. Thanks in advance..

Note: I have checked all Networking examples. So I already done basic things such as AllocateID etc.

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 Tidus-Yuna · Nov 04, 2012 at 08:43 AM 1
Share

Sure I can.. But that would be better if someone answer like one of those: "You cannot send RPC from a client to other specific client using normal version of RPC. Only server can do it." Or: "You can send RPC from client to specific client. But you need to do......."

1 Reply

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

Answer by Fattie · Oct 25, 2012 at 03:47 PM

the answer is very simple, thank goodness .....

never, ever use the "first" version of the RPC call un Unity.

(just as you never use nonsense like "network instantiate"

Massive novel-length discussion ! --->

http://answers.unity3d.com/questions/326626/games-with-multiple-maps.html

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

Comment
Add comment · Show 3 · 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 Tidus-Yuna · Oct 26, 2012 at 08:25 PM 0
Share

Thanks for the answer!) I have checked links. I already used "normal" version of RPC and don't use "Network.instantiate".

$$anonymous$$aybe I am wrong but it seems we cannot send "normal" RPC from a client to other specific client. So now I only send position info to server and then from server to all other specific clients.

avatar image Fattie · Oct 31, 2012 at 08:36 AM 0
Share

you have to get the address, I mean the ID, FRO$$anonymous$$ the server (boss iPad) you know?

avatar image Tidus-Yuna · Oct 31, 2012 at 10:58 AM 0
Share

Yes I know.. I send new view IDs to all clients from server.. But I couldn't manage to send RPC from client to other client. (which is unnecessary for me now, because I handle everything on server then send RPC to other clients from server).

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

10 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

Related Questions

Does the position change need state synchronization? 2 Answers

Problem with Playmaker Send Remote Event 1 Answer

Is it "bad" to use RPCs to synchronize movement? 1 Answer

RPC with Network View 0 Answers

get return on networkView.RPC 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