Hey guys, I Keep getting error “GameObject is destroyed but your still trying to access it”
Im confused because I havent stated to destroy any gameobject in my code
public void decrementLives()
{
Debug.Log(gameObject.name + " has lost a life");
lives--;
spawnSparks();
if (lives == 0)
{
Debug.Log("Destroying " + gameObject.name + " on the server");
// tell all clients to destroy the player's ship
//game.getNetworkView().RPC("DestroyShip", RPCMode.OthersBuffered, gameObject.name);
spawnExplosion();
// destroy player's ship on server
//Destroy(gameObject);
Application.LoadLevel("Level2");
}
}
[RPC]
public void DecrementLives(string shipName)
{
GameObject ship = GameObject.Find(shipName);
ShipController shipScript = (ShipController)ship.GetComponent("ShipController");
shipScript.lives--;
spawnSparks();
if(shipScript.lives == 0)
{
//game.getNetworkView().RPC("DestroyShip", RPCMode.OthersBuffered, gameObject.name);
spawnExplosion();
//Destroy(gameObject);
Application.LoadLevel("Level2");
}
}