/// <summary> /// Returns true if player is facing away from the bed. /// </summary> /// <param name="player"></param> /// <returns></returns> public bool CheckPlayerFacing(Transform player) { float leftAngle = ArcFunctions.AngleHalf(Vector3.up, player.transform.forward, Vector3.forward); float forwardAngle = ArcFunctions.AngleHalf(Vector3.up, Camera.main.transform.forward, Vector3.left); if (leftAngle > facingTriggerDegree || forwardAngle < -facingTriggerDegree) { return(true); } else { return(false); } }
public override void Update() { base.Update(); #region Camera Math Vector3 dir = ((fireLight.transform.position + transform.position) / 2) - player.transform.position; float angleY = ArcFunctions.AngleHalf(dir, player.transform.forward, Vector3.up); float abs_AngleY = Mathf.Abs(angleY); float map_AngleY = map(abs_AngleY, 0, slowViewTriggerAngle, 1, 0); float anglePlayerX = ArcFunctions.AngleHalf(dir, cam.transform.forward, player.transform.right); float abs_AnglePlayerX = Mathf.Abs(anglePlayerX); float map_AnglePlayerX = map(abs_AnglePlayerX, 0, slowViewTriggerAngle, 1, 0); map_AngleXY = map_AngleY * map_AnglePlayerX; abs_Sum = abs_AnglePlayerX + abs_AnglePlayerX + abs_AngleY; #endregion #region Annoying Camera //player if (r_sleepScript.sleepState == SleepState.standing && abs_AngleY < slowViewTriggerAngle) { float y_rotate_Amount = map_AngleXY * map_AngleY * rotateAmount * Time.deltaTime; if (angleY > 0) { r_mouseLook.TriggerFirePlayerRotate(y_rotate_Amount); } else { r_mouseLook.TriggerFirePlayerRotate(-y_rotate_Amount); } if (abs_AnglePlayerX < slowViewTriggerAngle) { float x_rotate_Amount = map_AngleXY * map_AnglePlayerX * rotateAmount * Time.deltaTime; if (anglePlayerX > 0) { r_mouseLook.TriggerFireCameraRotate(x_rotate_Amount); } else { r_mouseLook.TriggerFireCameraRotate(-x_rotate_Amount); } } } #endregion #region LookAtTrigger if (Interaction.reticule == LookingAt.Fire) { lookingAtFire = true; lookAtFireTimer += Time.deltaTime; } else { lookingAtFire = false; lookAtFireTimer -= Time.deltaTime / 2; if (lookAtFireTimer < 0) { lookAtFireTimer = 0; } } #endregion #region fireEffects float fireTimerPercentage = lookAtFireTimer / lookAtFireTimerMax; foreach (Rotate rot in flameArray) { rot.speed = flameRotateSpeedNormal + fireTimerPercentage * flameRotateSpeedModifier; } particles.SetEmissionRate(2 + fireTimerPercentage * 4); fireLight.intensity = lightIntensityNormal + fireTimerPercentage * lightIntensityModifier; float newScaleNumber = 0.5f + fireTimerPercentage; transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(1, newScaleNumber, 1), 0.2f); #endregion if (lookAtFireTimer > lookAtFireTimerMax) { DreamTriggerEffect(); } }