/** * Awake- Used by Unity for initialization * Finds all component children that this player has and caches them */ void Awake() { movementScript = transform.FindChild("MovementController").GetComponent <PlayerMovementScript> (); if (movementScript == null) { Debug.LogError("Could not load Player Movement Script"); } inputScript = transform.FindChild("InputController").GetComponent <PlayerInputScript> (); if (inputScript == null) { Debug.LogError("Could not load Player Input Script"); } networkScript = transform.FindChild("NetworkController").GetComponent <NetworkControllerScript> (); if (inputScript == null) { Debug.LogError("Could not load Network Controller Script"); } visionScript = transform.FindChild("VisionController").GetComponent <VisionControllerScript> (); if (visionScript == null) { Debug.LogError("Could not load Vision Controller Script"); } environmentScript = transform.FindChild("EnvironmentController").GetComponent <PlayerEnvironmentController> (); if (environmentScript == null) { Debug.LogError("Could not load Player Environment Controller Script"); } healthScript = transform.FindChild("HealthController").GetComponent <PlayerHealthScript> (); if (healthScript == null) { Debug.LogError("Could not load Player Health Script"); } }
/* * Awake- Unity uses this for initialization * Attempts to cache the player controller and player environment controller */ void Awake() { player = transform.parent.GetComponent <PlayerControllerScript> (); if (player == null) { Debug.LogError("Could not find player script."); } playerEnv = player.transform.FindChild("EnvironmentController").GetComponent <PlayerEnvironmentController> (); if (playerEnv == null) { Debug.LogError("Could not find player environment script."); } }