Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        rightFoot.Update();
        leftFoot.Update();
        float rightFootPos = rightFoot.transform.localPosition.z;
        float leftFootPos  = leftFoot.transform.localPosition.z;

        if (rightFootPos > rightFoot.localStandardPos.z && leftFootPos > leftFoot.localStandardPos.z)
        {
            if (rightFootPos > leftFootPos)
            {
                rightFoot.worldPosition = rightFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
            else
            {
                leftFoot.worldPosition = leftFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
        }
        else if (rightFootPos < rightFoot.localStandardPos.z && leftFootPos < leftFoot.localStandardPos.z)
        {
            if (rightFootPos < leftFootPos)
            {
                rightFoot.worldPosition = rightFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
            else
            {
                leftFoot.worldPosition = leftFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
        }
        rightFootPos = rightFoot.transform.localPosition.x;
        leftFootPos  = leftFoot.transform.localPosition.x;
        if (rightFootPos > rightFoot.localStandardPos.x && leftFootPos > leftFoot.localStandardPos.x)
        {
            if (rightFootPos > leftFootPos)
            {
                rightFoot.worldPosition = rightFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
            else
            {
                leftFoot.worldPosition = leftFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
        }
        else if (rightFootPos < rightFoot.localStandardPos.x && leftFootPos < leftFoot.localStandardPos.x)
        {
            if (rightFootPos < leftFootPos)
            {
                rightFoot.worldPosition = rightFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
            else
            {
                leftFoot.worldPosition = leftFoot.localStandardPos + transform.position + rigidbody.velocity * velocityPredict;
            }
        }
    }