Пример #1
0
    void StartRandomWalk()
    {
        behaviourNormalTimer.cd = Random.Range(0.4f, 0.75f);

        input.positionInput = Random.insideUnitCircle;

        const float lerpHome = 0.9f;

        input.positionInput = input.positionInput * lerpHome - ToClosestHome() * (1 - lerpHome);

        const float lerpAvoid3 = 0.85f;

        input.positionInput = input.positionInput * lerpAvoid3 - VisionBlocker.ToThirdClosestAvoidPoint(transform.position) * (1 - lerpAvoid3);

        const float lerpAvoid2 = 0.75f;

        input.positionInput = input.positionInput * lerpAvoid2 - VisionBlocker.ToSecondClosestAvoidPoint(transform.position) * (1 - lerpAvoid2);

        const float lerpAvoid = 0.65f;

        input.positionInput = input.positionInput * lerpAvoid - VisionBlocker.ToClosestAvoidPoint(transform.position) * (1 - lerpAvoid);
    }
Пример #2
0
    void StartRandomFlee()
    {
        behaviourPaniqueTimer.cd = Random.Range(0.115f, 0.2f);

        Vector3 toPlayer = (transform.position - perception.lastPlayerPosition);

        toPlayer.y = 0;
        toPlayer.Normalize();

        input.positionInput = Random.insideUnitCircle;

        //const float lerpAvoid3 = 0.7f;
        //input.positionInput = input.positionInput * lerpAvoid3 - VisionBlocker.ToThirdClosestAvoidPoint(transform.position) * (1 - lerpAvoid3);

        //const float lerpAvoid2 = 0.9f;
        //input.positionInput = input.positionInput * lerpAvoid2 - VisionBlocker.ToSecondClosestAvoidPoint(transform.position) * (1 - lerpAvoid2);

        const float lerpAvoid = 0.95f;

        input.positionInput = input.positionInput * lerpAvoid - VisionBlocker.ToClosestAvoidPoint(transform.position) * (1 - lerpAvoid);


        if (canBeAccomondated)
        {
            const float lerpFactor = 0.75f;
            input.positionInput = input.positionInput * lerpFactor + new Vector2(toPlayer.x, toPlayer.z) * (1 - lerpFactor);


            const float lerpHome = 0.85f;
            input.positionInput = input.positionInput * lerpHome + ToClosestHome() * (1 - lerpHome);
        }
        else
        {
            const float lerpFactor = 0.65f;
            input.positionInput = input.positionInput * lerpFactor - new Vector2(toPlayer.x, toPlayer.z) * (1 - lerpFactor);
        }
        Debug.DrawRay(transform.position, toPlayer, Color.green, 0.5f);
    }