UnityEngine.GameObject.GetComponent () (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:27)
xa.Start () (at Assets/Scripts/xa.cs:30)
I get this error when i go to run my game
Here is my code
using UnityEngine;
using System.Collections;
public class xa : MonoBehaviour
{
public static Ball ball;
public static AudioManager audioManager;
public static ScoreManager scoreManager;
public static Player1 player1;
public static Player2 player2;
//public static Player3 player3;
//public static Player4 player4;
public static bool gameOver = false;
// set to false if game is configured for CTF
public static bool letsPlayKeepaway = false;
// layers
public const int Team1Goal = 9;
public const int Team2Goal = 10;
void Start()
{
// cache these so they can be accessed by other scripts
ball = GameObject.FindWithTag("Ball").GetComponent<Ball>();
scoreManager = gameObject.GetComponent<ScoreManager>();
audioManager = gameObject.GetComponent<AudioManager>();
player1 = GameObject.Find("Player1").GetComponent<Player1>();
player2 = GameObject.Find("Player2").GetComponent<Player2>();
//player3 = GameObject.Find("Player3").GetComponent<Player3>();
//player4 = GameObject.Find("Player4").GetComponent<Player4>();
}
}
I dont know what i need to change or set ?
If anyone has some advice?
I have never work on a game/game-prototype that uses network/server, so I have no experience on that. The only thing I am sure of is that
– Chronos-LPlayer1does not exist (yet) when theGameObject.Find()is called in theStart()of thexa.cs.By
– Chronos-LInstantiate()?Before that, you have said that I start with an empty scene and when i join the server it creates a player. What do you mean by when I join the server, it creates a player?
– Chronos-L