public ApplyFallImpact ( float impact ) : void | ||
impact | float | |
return | void |
/////////////////////////////////////////////////////////// // applies various forces to the camera and weapon springs // in response to falling impact /////////////////////////////////////////////////////////// public void ApplyFallImpact(float impact) { float posImpact = impact * PositionKneeling; float rotImpact = impact * RotationKneeling; // smooth step the impacts to make the springs react more subtly // from short falls, and more aggressively from longer falls posImpact = Mathf.SmoothStep(0, 1, posImpact); posImpact = Mathf.Clamp01(posImpact); rotImpact = Mathf.SmoothStep(0, 1, rotImpact); rotImpact = Mathf.SmoothStep(0, 1, rotImpact); rotImpact = Mathf.Clamp01(rotImpact); // apply impact to camera position spring if (m_PositionSpring != null) { m_PositionSpring.AddForce(new Vector3(0, -posImpact, 0)); } // apply impact to camera rotation spring if (m_RotationSpring != null) { float roll = Random.value > 0.5f ? (rotImpact * 2) : -(rotImpact * 2); m_RotationSpring.AddForce(new Vector3(0, 0, roll)); } // apply falling impact on the current weapon, if present if (m_CurrentWeapon != null) { m_CurrentWeapon.ApplyFallImpact(posImpact); } }