Ejemplo n.º 1
0
    void FixedUpdate()
    {
        angles = SpringInterpolator.Sperp(angles, targetAngles, ref springVelocity, mass, springConstant, dragConstant, Time.fixedDeltaTime);
        transform.localRotation = Quaternion.Euler(angles);

        // recover
        targetAngles = Vector3.Slerp(targetAngles, Vector3.zero, Time.fixedDeltaTime * recoverSpeed);
    }
Ejemplo n.º 2
0
    void LateUpdate()
    {
        if (Time.timeScale == 0 || Time.fixedDeltaTime == 0)
        {
            return;
        }

        fixedDeltaTimeChange = baseTransform.forward - oldForward;

        change     = baseTransform.InverseTransformDirection(fixedDeltaTimeChange) / Time.fixedDeltaTime;
        oldForward = baseTransform.forward;

        targetChange = SpringInterpolator.Sperp(targetChange, Vector3.ClampMagnitude(change, maxOffset), ref springvelocity, mass, springConstant, dragConstant, Time.fixedDeltaTime);

        //Debug.DrawRay(baseTransform.position + baseTransform.forward, targetChange);

        transform.localRotation = Quaternion.LookRotation(Vector3.forward + targetChange, Vector3.up);
    }