public void AssignFPCamera() { if (KickStarter.player) { firstPersonCamera = KickStarter.player.GetComponentInChildren <FirstPersonCamera>(); } }
private void Awake() { if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } if (GetComponentInChildren <SkinnedMeshRenderer>()) { skinnedMeshRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); } if (KickStarter.playerMovement) { Transform fpCamTransform = KickStarter.playerMovement.AssignFPCamera(); if (fpCamTransform != null) { fpCam = KickStarter.playerMovement.AssignFPCamera(); if (fpCam != null) { firstPersonCamera = fpCam.GetComponent <FirstPersonCamera>(); } } } if (gameObject.tag != Tags.player) { ACDebug.LogWarning("The Player '" + gameObject.name + "' must be tagged as Player in its Inspector."); } _Awake(); }
public void AssignFPCamera () { if (GameObject.FindWithTag (Tags.firstPersonCamera) && GameObject.FindWithTag (Tags.firstPersonCamera).GetComponent <FirstPersonCamera>()) { firstPersonCamera = GameObject.FindWithTag (Tags.firstPersonCamera).GetComponent <FirstPersonCamera>(); } }
/** * Assigns the first-person camera as the FirstPersonCamera component placed as a child component on the Player preab. */ public void AssignFPCamera() { if (KickStarter.player) { firstPersonCamera = KickStarter.player.GetComponentInChildren<FirstPersonCamera>(); } }
public override void OnInspectorGUI() { FirstPersonCamera _target = (FirstPersonCamera)target; EditorGUILayout.BeginVertical("Button"); _target.headBob = EditorGUILayout.Toggle("Bob head when moving?", _target.headBob); if (_target.headBob) { _target.headBobMethod = (FirstPersonHeadBobMethod)EditorGUILayout.EnumPopup("Head-bob method:", _target.headBobMethod); if (_target.headBobMethod == FirstPersonHeadBobMethod.BuiltIn) { _target.builtInSpeedFactor = EditorGUILayout.FloatField("Speed factor:", _target.builtInSpeedFactor); _target.bobbingAmount = EditorGUILayout.FloatField("Height change factor:", _target.bobbingAmount); } else if (_target.headBobMethod == FirstPersonHeadBobMethod.CustomAnimation) { _target.headBobSpeedParameter = EditorGUILayout.TextField("Forward speed float parameter:", _target.headBobSpeedParameter); _target.headBobSpeedSideParameter = EditorGUILayout.TextField("Sideways speed float parameter:", _target.headBobSpeedSideParameter); if (_target.GetComponent <Animator>() == null) { EditorGUILayout.HelpBox("This GameObject must have an Animator component attached.", MessageType.Warning); } } else if (_target.headBobMethod == FirstPersonHeadBobMethod.CustomScript) { EditorGUILayout.HelpBox("The component's public method 'GetHeadBobSpeed' will return the desired head-bobbing speed.", MessageType.Info); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); _target.allowMouseWheelZooming = EditorGUILayout.Toggle("Allow mouse-wheel zooming?", _target.allowMouseWheelZooming); if (_target.allowMouseWheelZooming) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Min FOV:", labelWidth); _target.minimumZoom = EditorGUILayout.FloatField(_target.minimumZoom, intWidth); EditorGUILayout.LabelField("Max FOV:", labelWidth); _target.maximumZoom = EditorGUILayout.FloatField(_target.maximumZoom, intWidth); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Constrain pitch-rotation (degrees)"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Min:", labelWidth); _target.minY = EditorGUILayout.FloatField(_target.minY, intWidth); EditorGUILayout.LabelField("Max:", labelWidth); _target.maxY = EditorGUILayout.FloatField(_target.maxY, intWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); _target.sensitivity = EditorGUILayout.Vector2Field("Freelook sensitivity:", _target.sensitivity); EditorGUILayout.EndVertical(); UnityVersionHandler.CustomSetDirty(_target); }
protected void Awake() { if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } skinnedMeshRenderers = GetComponentsInChildren <SkinnedMeshRenderer>(); if (KickStarter.playerMovement) { Transform fpCamTransform = KickStarter.playerMovement.AssignFPCamera(); if (fpCamTransform != null) { fpCam = KickStarter.playerMovement.AssignFPCamera(); if (fpCam != null) { firstPersonCamera = fpCam.GetComponent <FirstPersonCamera>(); } } } if (gameObject.tag != Tags.player) { ACDebug.LogWarning("The Player '" + gameObject.name + "' must be tagged as Player in its Inspector.", gameObject); } _Awake(); if (GetAnimEngine() != null && KickStarter.settingsManager != null && KickStarter.settingsManager.hotspotDetection == HotspotDetection.PlayerVicinity && GetAnimEngine().isSpriteBased&& hotspotDetector != null) { if (spriteChild != null && hotspotDetector.transform == spriteChild) { } // OK else if (turn2DCharactersIn3DSpace) { if (hotspotDetector.transform == transform) { ACDebug.LogWarning("The Player '" + name + "' has a Hotspot Detector assigned, but it is on the root. Either parent it to the 'sprite child' instead, or check 'Turn root object in 3D space?' in the Player Inspector.", this); } else if (hotspotDetector.transform.parent == transform) { ACDebug.LogWarning("The Player '" + name + "' has a Hotspot Detector assigned, but it is a direct child of a 2D root. Either parent it to the 'sprite child' instead, or check 'Turn root object in 3D space?' in the Player Inspector.", this); } } } }
public override void OnInspectorGUI() { FirstPersonCamera _target = (FirstPersonCamera)target; EditorGUILayout.BeginVertical("Button"); _target.headBob = EditorGUILayout.BeginToggleGroup("Bob head when moving?", _target.headBob); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Speed:", labelWidth); _target.bobbingSpeed = EditorGUILayout.FloatField(_target.bobbingSpeed, intWidth); EditorGUILayout.LabelField("Amount:", labelWidth); _target.bobbingAmount = EditorGUILayout.FloatField(_target.bobbingAmount, intWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); _target.allowMouseWheelZooming = EditorGUILayout.BeginToggleGroup("Allow mouse-wheel zooming?", _target.allowMouseWheelZooming); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Min FOV:", labelWidth); _target.minimumZoom = EditorGUILayout.FloatField(_target.minimumZoom, intWidth); EditorGUILayout.LabelField("Max FOV:", labelWidth); _target.maximumZoom = EditorGUILayout.FloatField(_target.maximumZoom, intWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Constrain pitch-rotation (degrees)"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Min:", labelWidth); _target.minY = EditorGUILayout.FloatField(_target.minY, intWidth); EditorGUILayout.LabelField("Max:", labelWidth); _target.maxY = EditorGUILayout.FloatField(_target.maxY, intWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); _target.sensitivity = EditorGUILayout.Vector2Field("Freelook sensitivity:", _target.sensitivity); EditorGUILayout.EndVertical(); if (GUI.changed) { EditorUtility.SetDirty(_target); } }
/** * A<summary>ssigns the first-person camera as the FirstPersonCamera component placed as a child component on the Player preab.</summary> * <returns>The Transform of the FirstPersonCamera component, if one is present on the Player.</returns> */ public Transform AssignFPCamera() { if (KickStarter.player) { firstPersonCamera = KickStarter.player.GetComponentInChildren<FirstPersonCamera>(); if (firstPersonCamera == null && KickStarter.settingsManager.movementMethod == MovementMethod.FirstPerson && KickStarter.player.FirstPersonCamera == null) { ACDebug.LogWarning ("Could not find a FirstPersonCamera script on the Player - one is necessary for first-person movement."); } if (firstPersonCamera != null) { return firstPersonCamera.transform; } } return null; }
/** * A<summary>ssigns the first-person camera as the FirstPersonCamera component placed as a child component on the Player preab.</summary> * <returns>The Transform of the FirstPersonCamera component, if one is present on the Player.</returns> */ public Transform AssignFPCamera() { if (KickStarter.player) { firstPersonCamera = KickStarter.player.GetComponentInChildren <FirstPersonCamera>(); if (firstPersonCamera == null && KickStarter.settingsManager.movementMethod == MovementMethod.FirstPerson && KickStarter.player.FirstPersonCamera == null) { ACDebug.LogWarning("Could not find a FirstPersonCamera script on the Player - one is necessary for first-person movement."); } if (firstPersonCamera != null) { return(firstPersonCamera.transform); } } return(null); }
protected new void Awake() { if (soundChild && soundChild.gameObject.GetComponent <AudioSource>()) { audioSource = soundChild.gameObject.GetComponent <AudioSource>(); } skinnedMeshRenderers = GetComponentsInChildren <SkinnedMeshRenderer>(); if (KickStarter.playerMovement) { firstPersonCamera = GetComponentInChildren <FirstPersonCamera>(); if (firstPersonCamera == null && KickStarter.settingsManager.movementMethod == MovementMethod.FirstPerson && KickStarter.player.FirstPersonCamera == null) { ACDebug.LogWarning("Could not find a FirstPersonCamera script on the Player - one is necessary for first-person movement.", KickStarter.player); } if (firstPersonCamera != null) { firstPersonCameraTransform = firstPersonCamera.transform; } } _Awake(); if (GetAnimEngine() != null && KickStarter.settingsManager != null && KickStarter.settingsManager.hotspotDetection == HotspotDetection.PlayerVicinity && GetAnimEngine().isSpriteBased&& hotspotDetector != null) { if (spriteChild != null && hotspotDetector.transform == spriteChild) { } // OK else if (turn2DCharactersIn3DSpace) { if (hotspotDetector.transform == transform) { ACDebug.LogWarning("The Player '" + name + "' has a Hotspot Detector assigned, but it is on the root. Either parent it to the 'sprite child' instead, or check 'Turn root object in 3D space?' in the Player Inspector.", this); } else if (hotspotDetector.transform.parent == transform) { ACDebug.LogWarning("The Player '" + name + "' has a Hotspot Detector assigned, but it is a direct child of a 2D root. Either parent it to the 'sprite child' instead, or check 'Turn root object in 3D space?' in the Player Inspector.", this); } } } }
public void SetFirstPerson() { FirstPersonCamera firstPersonCamera = KickStarter.player.GetComponentInChildren <FirstPersonCamera>(); if (firstPersonCamera) { SetGameCamera(firstPersonCamera); SnapToAttached(); } if (attachedCamera) { if (lastNavCamera != attachedCamera) { lastNavCamera2 = lastNavCamera; } lastNavCamera = attachedCamera; } }
private void OnDestroy() { firstPersonCamera = null; }
private void OnDestroy () { firstPersonCamera = null; playerInput = null; settingsManager = null; sceneSettings = null; playerMenus = null; navigationManager = null; }
protected void OnDestroy() { firstPersonCamera = null; }