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 MaZy · Aug 04, 2012 at 05:48 PM · gameobjectserverrpcinputsdedicated

RPC Call problem 1 gameobject 1 prefab

Hello,

I can't explain this myself so I have need little bit help. I have 2 things. One prefab.. which is player with scripts for movement and a script "controller" which sends via RPCs inputs to the server. The other thing is a empty gameobject "spawnpoint" has a script "AuthPlayerhandler". The playerhandler script does work with things example player joining, put it to lists, and send to players.. if he does request spawn, then send to others. And also has the "OnInput" RPC function. But my problem is.. the player prefab has controller.cs. There is also the OnInput RPC Function. So it means they are not in same script.

How could I clear this?

My I idea was to make public gameobject variable. But then my Spawnpoint need a prefab. When I do this.. I get error like "SceneID: 1 ..." bla bla.

Code controller.cs in Playerprefab

     public GameObject playerHandler;
  
  void Update() {
  
  if(Network.isClient) {
  if(Input.GetAxis("Vertical") > 0) {
  playerHandler.GetComponent<AuthPlayerhandler>().networkView.RPC("OnInput", RPCMode.Server, Network.player, "Vertical", (Input.GetAxis("Vertical")));
  }
  }
  
  }
 
 AuthPlayerhandler.cs
 
     [RPC]
  void OnInput(NetworkPlayer player, string input, float val)
  {
  Debug.Log("Got Input from Player: " + player + ". Input: " + input + " Value: " + val);
  
  
  
  Playerclass playerInstance = getPlayerInstance(player);
  
  //Debug
  if(input == "Velocity") {
  playerInstance.Velocity = val;
  }
  if(input == "Steer") {
  playerInstance.Steer = val; 
  }
  
  
  }

EDIT: Wanted say Spawnpoint gameobject is in hierarchy. Playerperfab will spawn when player request spawn

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 · Feb 19, 2013 at 01:32 AM 0
Share

Please properly format your code andI'll answer your 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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to Send RPC from One Client to anther while the server isn't in the same scene 1 Answer

Moveing my camera 1 Answer

Networking RPC calls never sent to other clients 1 Answer

Server don't receiving RPC values 0 Answers

What, how? Dedicated Servers? 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