Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Tariq-mehmood · Jan 05, 2017 at 10:59 PM · networkingrpcclient-server

running car when button is pressed on client side

Dear All I am working of a project in which I have to control my car game using android client app now the problem I am facing is that when I pressed to go up button on app nothing happen and two errors show up on client side View ID SceneID: 2 Level Prefix: 0 not found during lookup. Strange behavior may occur and Received state update for view id' SceneID: 2 Level Prefix: 0' but the NetworkView doesn't exist now I have this script dataHandler and car selector in which dontdestoryonawake function is call so that on switching to another screen the selected car can be shown now this all i done by using RPC now i have created two functions in car selection script which has boolen variable and then that function is called those boolen values get true and as dontdestroyonawake is applied so those values are called on car controller script and other things are done now the problem is on loading a level through client side those error pop up and these values are not called on car controller script dataHandler script and car selection script is on gameobject name dataHandler on screen name carSelector and car controller script is attached to every car and data implemented in attached on gameobject data implementer in screen car controller need urgent help

Data Handler script

 public class dataHandler : MonoBehaviour {

 public int carSelected;
 public int dont = 8;
   //  [RPC]
         void Awake()
         {
             GameObject.DontDestroyOnLoad(this.gameObject);

         }
   
 // Use this for initialization
 void Start () {
     carSelected = 1;

 }

 [RPC]
 public void carSelect(int a)
 {
     carSelected = a;

 }
 
 // Update is called once per frame
 void Update () {
 
 }
 }

car Selection Script

 public class carSelection : MonoBehaviour {

 public GameObject Vulcan;
 public GameObject Spear;
 public GameObject Eclipse;
 public GameObject Bullet350;
 public GameObject Tsunami;
 public GameObject MaclaranF1;
 public GameObject Lamborgeni;
 public GameObject MaclaranMP4;
 public int carSelected;
 public bool _isRight;
 public bool _isLeft;
 public bool _isPressed;
 public bool _isUp;
 public bool _isDown;

   




 // Use this for initialization
 void Start () {
     Vulcan.SetActive(true);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(false);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(false);
     carSelected = 1;
 }
 
 // Update is called once per frame
 void Update () {
 
 }

 [RPC]
 public void loadVulcan()
 {
     
         Vulcan.SetActive(true);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
         carSelected = 1;

     
 }

 [RPC]
 public void loadSpear()
 {
     
         Vulcan.SetActive(false);
         Spear.SetActive(true);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
        // carSelected = 2;
     
 }

 [RPC]
 public void loadEclipse()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(true);
     Bullet350.SetActive(false);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(false);
   //  carSelected = 3;
 }

 [RPC]
 public void loadBullet350()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(true);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(false);
     carSelected = 4;
 }

 [RPC]
 public void loadTsunami()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(false);
     Tsunami.SetActive(true);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(false);
     carSelected = 5;
 }

 [RPC]
 public void loadMaclaranF1()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(false);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(true);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(false);
     carSelected = 6;
 }

 [RPC]
 public void loadLamborgeni()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(false);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(true);
     MaclaranMP4.SetActive(false);
     carSelected = 7;
 }

 [RPC]
 public void loadMaclaranMP4()
 {
     Vulcan.SetActive(false);
     Spear.SetActive(false);
     Eclipse.SetActive(false);
     Bullet350.SetActive(false);
     Tsunami.SetActive(false);
     MaclaranF1.SetActive(false);
     Lamborgeni.SetActive(false);
     MaclaranMP4.SetActive(true);
     carSelected = 8;
 }


 [RPC]
 public void Back()
 {
     Application.LoadLevel("mainScreen");
 }

 
 [RPC]
 public void Up()
 {
     _isUp = true;
 }



 }

Data implementer Script

 public class dataImplementer : MonoBehaviour {
 public GameObject Vulcan;
 public GameObject Spear;
 public GameObject Eclipse;
 public GameObject Bullet350;
 public GameObject Tsunami;
 public GameObject MaclaranF1;
 public GameObject Lamborgeni;
 public GameObject MaclaranMP4;
 public int seletedCar;
 public int dont;
 public bool _isUp;


 // Use this for initialization
 void Start () {
 seletedCar  = GameObject.Find("dataHandler").GetComponent<dataHandler>().carSelected;
     

     Debug.Log(seletedCar);
     if(seletedCar == 1)
     {
         Vulcan.SetActive(true);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
     }
     else if(seletedCar == 2)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(true);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);

     }
     else if(seletedCar == 3)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(true);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
     }
     else if (seletedCar == 4)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(true);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
     }
     else if (seletedCar == 5)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(true);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
     }
     else if (seletedCar == 6)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(true);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(false);
     }
     else if (seletedCar == 7)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(true);
         MaclaranMP4.SetActive(false);
     }
     else if (seletedCar == 8)
     {
         Vulcan.SetActive(false);
         Spear.SetActive(false);
         Eclipse.SetActive(false);
         Bullet350.SetActive(false);
         Tsunami.SetActive(false);
         MaclaranF1.SetActive(false);
         Lamborgeni.SetActive(false);
         MaclaranMP4.SetActive(true);
         
     }
 }

 [RPC]
 public void Up()
 {
     _isUp = true;
 }


 // Update is called once per frame
 void Update () {
     Debug.Log(dont);
 }

}

Update function of Car controller

               void Update()
         {
     
         if (GameObject.Find("CarSelector").GetComponent<carSelection>()._isUp == true)
     {
         TireRR.motorTorque = 1000;
         TireRL.motorTorque = 1000;
     }

   
 }
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

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

110 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 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 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 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 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

Exiting a UNET lobby causes future ClientRPC calls to be ignored. 1 Answer

ClientRPC not called from command on client instance during Start() 0 Answers

SyncVar works not always 0 Answers

Sending NetworkPlayer object with ClientRpc 0 Answers

Spawning Network Objects from the client | Unity Netcode For Gameobjects 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