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;
}
}
Your answer
Follow this Question
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