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 MOLB · Mar 23, 2013 at 03:34 PM · networkingrpcname

RPC isn't called on objects with another name, even though they have the same script.

Hello

I have an object that has a script. The script calls a remote procedure call on itself, but only on object where the name hasn't been modified. How can I fix this?

Thanks in advance.

All of the examples below are in the same script.

     void Update()
     {
         //Let's send RPC calls to all the other players.
         networkView.RPC("DoSomething", RPCMode.Others);
     }
     
     //This is supposed to be called on all objects with this script.
     [RPC]
     void DoSomething()
     {
         //This only gets called on objects with the default name, and not on objects with modified names.
         Debug.Log("Prefab is doing something!");
     }

NOTE: All of this is in one script, but it doesn't get called on objects that don't have the default name.

Comment
Add comment · Show 10
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 dorpeleg · Mar 23, 2013 at 03:45 PM 0
Share

Please share some code, it's very hard to help without knowing the full problam

avatar image MOLB · Mar 23, 2013 at 04:16 PM 0
Share

I just gave you the full problem. I have one script that sends RPCs to all other players (it is still the same script), but it only sends to the objects with the original name (prefab name in the assets). It doesn't send to the same object if it has another name than the original prefab name.

avatar image dorpeleg · Mar 23, 2013 at 04:31 PM 0
Share

Just describing it is not enough.

Show the code that sends the RPCs (for example).

We can't find the problem if we can't see it.

avatar image MOLB · Mar 23, 2013 at 05:34 PM 0
Share

The thing is, that the RPCs work flawlessly, but only if the instantiated prefab has the same name as it had when it was instantiated. If I change the name, alternatively the tag, it won't receive the RPC.

avatar image dorpeleg · Mar 23, 2013 at 05:38 PM 0
Share

If you keep reasoning why you don't need to show code, then I can't help you, sorry.

Show more comments

1 Reply

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

Answer by dorpeleg · Mar 23, 2013 at 07:31 PM

NetworkView.RPC

In the description: A NetworkView must be attached to the GameObject where the RPC function is being called.

Do you have a NetworkView attached?

In the description: if two RPC functions in different scripts have the same name only one of them is called when RPC is invoked.

Maybe that's the problem.

You might also want to try changing the RPCMode and see if it makes any diffrence.

Comment
Add comment · Show 11 · 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 MOLB · Mar 23, 2013 at 08:02 PM 0
Share

I have a NetworkView attached to the objects, and I am only using one script for this. Though, I have attached the script to multiple objects, but I everything is in one class, one namespace, one script. I've always had one script, because I can't send remote procedure calls to another script. That is why I placed all the RPC sender and RPC receivers in one script. Even though I did this, it doesn't work.

avatar image dorpeleg · Mar 23, 2013 at 08:51 PM 0
Share

As you said: " //This is supposed to be called on all objects with this script."

It means you have more then one script. (even if its the same one)

So your problem is:

if two RPC functions in different scripts have the same name only one of them is called when RPC is invoked.

avatar image MOLB · Mar 23, 2013 at 10:21 PM 0
Share

"This is supposed to be called on all objects with THIS SCRIPT" - This means this script only. I only have ONE script. It doesn't communicate with itself, and that is the problem.

avatar image dorpeleg · Mar 24, 2013 at 12:07 AM 0
Share

I Don't think you understand.

"all OBJECTS with THIS SCRIPT"

That means each object has another copy of the script (even if it is the same) and that is why only one RPC is called.

avatar image MOLB · Mar 24, 2013 at 07:56 AM 0
Share

Yes, they have another copy of the script, but when you call a remote procedure call it is sent to all instances of the script (class). All objects have the same script and the same class, therefor it should be called on all the objects with this script.

Let's say I call "DoSomething" to all players. Then the "[RPC] void DoSomething()" should be activated on all copies of the script, on all players. In my case, it only gets activated on objects with the name/tag it had in the assets.

The objects have NetworkViews attached, and everything else that make them function properly.

By the way... If what you're saying is true, why can I send the message to the objects with default name/tag (they also have copies of the script, just like the renamed objects)?

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.

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

Multiplayer Chat Script (Problem : mixed names) 1 Answer

problem with raycasts and tags 1 Answer

RPC call ending up on wrong target 1 Answer

RPC setName() not working correctly 0 Answers

supplied parameters doesn't match the rpc declaration 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