//constant spring force.
    void UpdateEarthQuake()
    {
        if (m_client == null || !m_client.UseEarthQuake || m_earthQuakeTimeTemp <= 0.0f || !EarthQuakeToggled)
        {
            return;
        }

        m_elapsedTime += Time.deltaTime;

        m_earthQuakeTimeTemp -= 0.0166f * (60 * Time.deltaTime);

        float magnitude = 0f;

        if (m_client.EarthQuakeMagTye == MAGTYPE.Fixed)
        {
            magnitude = m_client.EarthQuakeMagnitude;
        }
        else
        {
            magnitude = m_client.EarthQuakeMagCurve.Evaluate(m_elapsedTime);
        }

        // the horisontal move is a perlin noise value between 0 and
        // 'EarthQuakeMagnitude' (depending on 'EarthQuakeTime').
        // horizMove will ease out during the last second.
        Vector3 horizMove = Vector3.Scale(XftSmoothRandom.GetVector3Centered(1), new Vector3(magnitude,
                                                                                             0, magnitude)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);

        // the vertical move is half the earthquake magnitude and
        // has a 30% chance of occuring each frame. when it does,
        // it alternates between positive and negative. this produces
        // sharp shakes with nice spring smoothness inbetween.
        // vertMove will ease out during the last second.
        float vertMove = 0;

        if (UnityEngine.Random.value < 0.3f)
        {
            vertMove = UnityEngine.Random.Range(0, (magnitude * 0.35f)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);
            if (PositionSpring.State.y >= PositionSpring.RestState.y)
            {
                vertMove = -vertMove;
            }
        }

        PositionSpring.AddForce(horizMove);

        // apply earthquake roll force on the camera rotation spring
        RotationSpring.AddForce(new Vector3(0, 0, -horizMove.x * 2) * m_client.EarthQuakeCameraRollFactor);

        // vertical move is always applied to the camera spring.
        PositionSpring.AddForce(new Vector3(0, vertMove, 0));
    }
Exemple #2
0
 /// <summary>
 /// Adds a secondary positional force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 /// <param name="restAccumulation">The percent of the force to accumulate to the rest value.</param>
 public override void AddSecondaryPositionalForce(Vector3 force, float restAccumulation)
 {
     if (restAccumulation > 0) {
         m_SecondaryPositionSpring.RestValue += force * restAccumulation;
     }
     m_SecondaryPositionSpring.AddForce(force);
 }
Exemple #3
0
 /// <summary>
 /// Adds a secondary positional force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 /// <param name="restAccumulation">The percent of the force to accumulate to the rest value.</param>
 public override void AddSecondaryPositionalForce(Vector3 force, float restAccumulation)
 {
     if (restAccumulation > 0 && (m_AimAssist == null || !m_AimAssist.HasTarget()))
     {
         m_SecondaryPositionSpring.RestValue += force * restAccumulation;
     }
     m_SecondaryPositionSpring.AddForce(force);
 }
Exemple #4
0
 /// <summary>
 /// Adds a delayed rotational force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 /// <param name="restAccumulation">The percent of the force to accumulate to the rest value.</param>
 public override void AddSecondaryRotationalForce(Vector3 force, float restAccumulation)
 {
     if (restAccumulation > 0) {
         var springRest = m_SecondaryRotationSpring.RestValue;
         springRest.z += force.z * restAccumulation;
         m_SecondaryRotationSpring.RestValue = springRest;
     }
     m_SecondaryRotationSpring.AddForce(force);
 }
    void UpdatePosition()
    {
        SetWorldPosition(ref m_transitionPos);

        Vector3 position = transform.position;

        m_spring.AddForce(m_transitionPos, ref position);
        transform.position = position;
    }
Exemple #6
0
 /// <summary>
 /// Adds a delayed rotational force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 /// <param name="restAccumulation">The percent of the force to accumulate to the rest value.</param>
 public override void AddSecondaryRotationalForce(Vector3 force, float restAccumulation)
 {
     if (restAccumulation > 0 && (m_AimAssist == null || !m_AimAssist.HasTarget()))
     {
         m_Pitch += force.x * restAccumulation;
         m_Yaw   += force.y * restAccumulation;
         var springRest = m_SecondaryRotationSpring.RestValue;
         springRest.z += force.z * restAccumulation;
         m_SecondaryRotationSpring.RestValue = springRest;
     }
     m_SecondaryRotationSpring.AddForce(force);
 }
Exemple #7
0
 /// <summary>
 /// Adds a rotational force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 public override void AddRotationalForce(Vector3 force)
 {
     m_RotationSpring.AddForce(force);
 }
Exemple #8
0
 /// <summary>
 /// Adds a positional force to the ViewType.
 /// </summary>
 /// <param name="force">The force to add.</param>
 public override void AddPositionalForce(Vector3 force)
 {
     m_PositionSpring.AddForce(force);
 }