void Start() { rb = GetComponent <Rigidbody>(); animator = GetComponentInChildren <Animator>(); jumpMask = LayerMask.GetMask("Ground") | LayerMask.GetMask("EnemyCollider"); //Set up Input if (keyboard) { input = new KeyboardMousePlayerInputFactory(); } else { input = new GamepadPlayerInputFactory(); } input.Init(); //Turn off playermodel for localplayer, make others into enemies. if (isLocalPlayer) { foreach (SkinnedMeshRenderer mesh in playerModel) { mesh.enabled = false; } transform.position = FindObjectOfType <SpawnPoints>().GetRandomSpawn(); } else { myCamera.SetActive(false); foreach (GameObject box in hitbox) { box.layer = LayerMask.NameToLayer("EnemyHitbox"); box.tag = "Enemy"; } myCollider.layer = LayerMask.NameToLayer("EnemyCollider"); } //Set up crosshair texture crosshair = new Texture2D(1, 1); crosshair.SetPixel(0, 0, Color.black); crosshair.wrapMode = TextureWrapMode.Repeat; crosshair.Apply(); //Set up health bar texture healthBack = new Texture2D(1, 1); healthBack.SetPixel(0, 0, Color.gray); healthBack.wrapMode = TextureWrapMode.Repeat; healthBack.Apply(); healthBar = new Texture2D(1, 1); healthBar.SetPixel(0, 0, Color.red); healthBar.wrapMode = TextureWrapMode.Repeat; healthBar.Apply(); }
public GameObject InstantiatePlayer(int id, EInputType inputType) { if (PlayerList == null) { PlayerList = new List <Player>(); } GameObject PlayerGameObject = Instantiate(PlayerPrefab, spawnZone.transform.position, Quaternion.identity) as GameObject; PlayerGameObject.transform.SetRandomSpherePosition(EDomeLayer.LAYER0_CLOSE); Player newPlayer = PlayerGameObject.GetComponent <Player>(); newPlayer.Init(id, "Player " + PlayerCount.ToString()); PlayerInput pInput = PlayerInputFactory.GetInput(inputType, newPlayer); newPlayer.SetPlayerInput(pInput); PlayerList.Add(newPlayer); OnInstantiatePlayer.Invoke(newPlayer); return(PlayerGameObject); }