NetworkServer is not active. Cannot spawn objects without an active server in Unity 3D
<p>I am trying to implement a multiplayer feature in Unity3d. Its like a snake game, snake eats food and generate its part. I can successfully generate food and part as well but its not moving and giving me error "NetworkServer is not active. Cannot spawn objects without an active server." </p>

<p>Here is my code :-</p>

<pre><code>  private void CmdCheckForFood(Vector3 snakePartPosToBeInitialize,Vector3 headPos)
{

    if(_food != null)
    {
        if (_food.transform.position == headPos) // if food collide with head. 
        {
            _food.transform.position = GenerateRandomPosForFood(); 
               currPartOfSnake += 1;
            CmdCreatePartSnake(snakePartPosToBeInitialize);


        }
    }

}
public void CreatePartSnake(Vector3 snakePartPosToBeInitialize)
{
    GameObject obj = Instantiate(snakePart, snakePartPosToBeInitialize, Quaternion.identity) as GameObject;

    obj.name = "" + currPartOfSnake;
    obj.transform.parent = gameObject.transform;
    tail.Add(obj); // tail is list which contain all part of snake
    NetworkServer.Spawn(obj);
}
</code></pre>