- Home /
Error destroying player over network
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");
}
}
Comment
Answer by NoName115 · May 08, 2014 at 10:21 AM
Do you have a networkview on your GameObject?? that could be a problem.
Your answer
![](https://koobas.hobune.stream/wayback/20220613144500im_/https://answers.unity.com/themes/thub/images/avi.jpg)