/// <summary> /// Searches for its player object /// and references itself inside the magic system controller /// </summary> public override void OnStartClient() { this.spiritAnimationHandler = this.GetComponent <SpiritAnimationHandler>(); if (!this.hasAuthority) { return; } var player = this.GetPlayer(); this.spiritFollowManager = this.GetComponent <SpiritPlayerFollower>(); this.spiritFollowManager.Init(this, player); var magicSystemController = player.GetComponent <MagicSystemController>(); if (this.isWhiteSpirit) { magicSystemController.firstSpirit = this; } else { magicSystemController.secondSpirit = this; } }
/// <summary> /// Spawns two spirits which are searching for the player object /// </summary> public void SpawnSpirits(NetworkConnection conn, bool isSecondPlayer = false) { SpiritAnimationHandler backSpiritInstance = null; SpiritAnimationHandler whiteSpiritInstance = null; if (isSecondPlayer) { backSpiritInstance = Instantiate(this.blackSpiritSecondPlayer); whiteSpiritInstance = Instantiate(this.whiteSpiritSecondPlayer); } else { backSpiritInstance = Instantiate(this.blackSpirit); whiteSpiritInstance = Instantiate(this.whiteSpirit); } NetworkServer.Spawn(backSpiritInstance.gameObject, conn); NetworkServer.Spawn(whiteSpiritInstance.gameObject, conn); }