void OnValidate() { collider = collider == null?GetComponent <Collider>() : collider; shootPeanuts = shootPeanuts == null?GetComponent <Shoot_Peanuts>() : shootPeanuts; camouflageController = camouflageController == null?GetComponent <CamouflageController>() : camouflageController; sprintParticles = sprintParticles == null?particlePrefab.GetComponent <ParticleSystem>() : sprintParticles; }
private void Start() { m_playerActor = GetComponent <PlayerActor>(); m_sprintCooldown.End(); m_sprintDurationAfterSprintStopped.End(); m_shootPeanuts = GetComponent <Shoot_Peanuts>(); // get the transform of the main camera if (Camera.main != null) { m_cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject); // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them! } // get the third person character ( this should never be null due to require component ) m_character = GetComponent <ElephantMovement>(); m_interactor = GetComponent <Interactor>(); m_headControl = GetComponent <HeadControl>(); }