void Update() { if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouched, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); if (starIsOn && starTimer > 0f) { starTimer -= Time.deltaTime; m_Health.invincible = true; } else if (starIsOn && starTimer <= 0f) { m_Health.invincible = false; starIsOn = false; audioSource.Stop(); } // landing if (!starIsOn) { if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { if (!isDead && transform.position.y < killHeight) { OnDie(); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); audioSource.PlayOneShot(landSFX); } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
private void Update() { // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } /* * switch (state) * { * default: * case State.Normal: * HandleCharacterMovement(); * HandleHookShotStart(); * break; * } */ hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); HandleHookShotStart(); }
void Update() { // check for Y kill, //超过一定的高度就直接杀死 if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } hasJumpedThisFrame = false; //落地检查, bool wasGrounded = isGrounded; GroundCheck(); // 是否落地 if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (是否接受跌落伤害 && fallSpeedRatio > 0f) { //伤害的插值 float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // 坠落伤害的音效 SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX //着陆的音效 audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } //跟新玩家的高度,推测蹲下和站立的时候碰撞器大小不一样 UpdateCharacterHeight(false); //控制玩家的移动 HandleCharacterMovement(); }
void Update() { // check for Y kill // Yキルをチェックします if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing //着陸 if (isGrounded && !wasGrounded) { // Fall damage // ダメージを受ける float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX //落下ダメージSFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX // SFXを着陸させる audioSource.PlayOneShot(landSFX); } } // crouching //しゃがみ if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { // check for Y kill if (!isDead && transform.position.y < killHeight) { print("falling off screen"); m_Health.Kill(this.gameObject); return; } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } HandleCameraMovement(); CheckInteraction(); if (m_InputHandler.GetQuitPressed()) { Application.Quit(); } }
void Update() { hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); secondsSinceSave += Time.deltaTime; if (secondsSinceSave > 10) { secondsSinceSave = 0; saveLoad.Save(); } }
void Update() { // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCameraRotation(); HandleControllerSwitch(); CheckInteraction(); }
// Update is called once per frame void Update() { if (paused) { return; } hasJumpedThisFrame = false; if (focus == null) { bool wasGrounded = isGrounded; GroundCheck(); // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); } HandleCharacterMovement(); HandleInteractionMovement(); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { // if(PauseMenu.isOn) // { // Cursor.lockState = CursorLockMode.None; // Cursor.visible = true; // } // else //{ // Cursor.lockState = CursorLockMode.Locked; // Cursor.visible = false; // } } if (PauseMenu.isOn) { return; } // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill();//Important pas tout suite } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); //Important // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { if (timerActive) { timer += Time.deltaTime; int timeInSecondsInt = (int)timer; //We don't care about fractions of a second, so easy to drop them by just converting to an int int minutes = timeInSecondsInt / 60; //Get total minutes int seconds = timeInSecondsInt - (minutes * 60); //Get seconds for display alongside minutes timerText.text = minutes.ToString("D2") + ":" + seconds.ToString("D2"); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { //Can add fall damage //play landing sound lensdis.intensity.value = 0; vignett.intensity.value = 0; chrome.intensity.value = 0; } // crouching if (m_InputHandler.GetCrouchInputDown()) { addforce(transform.forward, slideSpeed); //lensdis.intensity.value = -60; chrome.intensity.value = 1; //vignett.intensity.value = 0.5f; SetCrouchingState(true, false); } if (m_InputHandler.GetCrouchInputReleased()) { lensdis.intensity.value = 0; chrome.intensity.value = 0; vignett.intensity.value = 0; SetCrouchingState(false, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); if (isCrouching) { addforce(transform.forward, slideSpeed); } if (Input.GetAxis("Mouse ScrollWheel") > 0f) // forward { if (activeWeapon >= 1 && weaponList.Count > 1) { weaponList[activeWeapon].SetActive(false); activeWeapon -= 1; weaponList[activeWeapon].SetActive(true); } } else if (Input.GetAxis("Mouse ScrollWheel") < 0f) // backwards { if (activeWeapon < (weaponList.Count - 1) && weaponList.Count > 1) { weaponList[activeWeapon].SetActive(false); activeWeapon += 1; weaponList[activeWeapon].SetActive(true); } } if (transform.position.y < -30) { transform.position = checkpoints[checkpoints.Count - 1]; } }
void Update() { if (isDead) { return; } // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); //reset the boost's charge if it has expired its duration on the ground if (m_JumpBoostDuration <= 0) { m_JumpBoostCharge = 0; } //subtract from bhop speed boost dyration if (isGrounded && m_JumpBoostDuration > 0) { m_JumpBoostDuration--; } // landing if (isGrounded && !wasGrounded) { //reset the jump boost duration on landing m_JumpBoostDuration = jumpBoostDuration; // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }
void Update() { child.transform.rotation = Quaternion.Euler(0.0f, 0.0f, gameObject.transform.rotation.z * -1.0f); switch (state) { default: case State.Normal: HandleHookShotStart(); // check for Y kill if (!isDead && transform.position.y < killHeight) { m_Health.Kill(); } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); // landing if (isGrounded && !wasGrounded) { // Fall damage float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { float dmgFromFall = Mathf.Lerp(fallDamageAtMinSpeed, fallDamageAtMaxSpeed, fallSpeedRatio); m_Health.TakeDamage(dmgFromFall, null); // fall damage SFX audioSource.PlayOneShot(fallDamageSFX); } else { // land SFX audioSource.PlayOneShot(landSFX); } } // crouching if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); break; case State.HookShotThrown: HandleHookshotThrow(); HandleCharacterMovement(); break; case State.HookShotFlyingPlayer: HandleHookShotMovement(); { // rotate the transform with the input speed around its local Y axis transform.Rotate(new Vector3(0f, (m_InputHandler.GetLookInputsHorizontal() * rotationSpeed * RotationMultiplier), 0f), Space.Self); } // vertical camera rotation { // add vertical inputs to the camera's vertical angle m_CameraVerticalAngle += m_InputHandler.GetLookInputsVertical() * rotationSpeed * RotationMultiplier; // limit the camera's vertical angle to min/max m_CameraVerticalAngle = Mathf.Clamp(m_CameraVerticalAngle, -89f, 89f); // apply the vertical angle as a local rotation to the camera transform along its right axis (makes it pivot up and down) playerCamera.transform.localEulerAngles = new Vector3(m_CameraVerticalAngle, 0, 0); } break; } }
void Update() { if (m_InputHandler.GetAimInputHeld()) { if (playerCamera.fieldOfView > 40.3f) { playerCamera.fieldOfView -= 0.3f; } } else { if (playerCamera.fieldOfView < 60.3f) { playerCamera.fieldOfView += 0.3f; } } if (vignette != null) { if (isCrouching && vignette.weight < 1) { vignette.weight += 0.01f; if (vignette.weight > 1) { vignette.weight = 1; } } if (!isCrouching && vignette.weight > 0.0f) { vignette.weight -= 0.005f; if (vignette.weight < 0) { vignette.weight = 0; } } } hasJumpedThisFrame = false; bool wasGrounded = isGrounded; GroundCheck(); if (isGrounded && !wasGrounded) { float fallSpeed = -Mathf.Min(characterVelocity.y, m_LatestImpactSpeed.y); float fallSpeedRatio = (fallSpeed - minSpeedForFallDamage) / (maxSpeedForFallDamage - minSpeedForFallDamage); if (recievesFallDamage && fallSpeedRatio > 0f) { // audioSource.PlayOneShot(fallDamageSFX); } else { audioSource.PlayOneShot(landSFX); } } if (m_InputHandler.GetFlashlightInputDown()) { if (!flashlight.enabled) { flashlightOff.Play(); } else { flashlightOn.Play(); } flashlight.enabled = !flashlight.enabled; } if (m_InputHandler.GetCrouchInputDown()) { SetCrouchingState(!isCrouching, false); } UpdateCharacterHeight(false); HandleCharacterMovement(); }