/// <summary> /// Initialise require components. /// </summary> void Start() { /// Attempt to extract and set the FollowCam component. if (GetComponent <FollowCamMovement>() is FollowCamMovement movementComponent) { cameraMotion = movementComponent; } else { /// throw exception if this failed. Debug.LogError("Failed to detect a FollowCamMovement component on camera game object."); throw new System.ArgumentNullException("No FollowCamMovement found on camera."); } }
/// <summary> /// Set the camera, camera requires a FollowCamMovement component attached. /// Logs an error if failed to find component. /// </summary> /// <param name="camera">Camera game object with FollowCamMovement component.</param> public void setCamera(Camera camera) { /// Set the camera this.camera = camera; /// Attempt to extract and set the FollowCam component. if (camera.GetComponent <FollowCamMovement>() is FollowCamMovement movementComponent) { cameraMotion = movementComponent; } else { /// throw exception is this failed. Debug.LogError("Failed to detect a FollowCamMovement component on camera game object."); throw new ArgumentNullException("No FollowCamMovement found on camera."); } }