Esempio n. 1
0
    private void Update()
    {
        SetFrameNeighbours();

        Vector3 SteeringForce = Steering.Pursuit(Player.Instance) * Seek;

        SteeringForce += Steering.Wander() * Wander;
        SteeringForce += Steering.Separation() * Separation;
        SteeringForce += Steering.Alignment() * Alightment;
        SteeringForce += Steering.Cohesion() * Cohesion;
        Vector3 Avoidance = Steering.ObstacleAvoidance();

        if (Avoidance.magnitude > float.Epsilon)
        {
            SteeringForce = Avoidance;
        }
        Velocity += SteeringForce * Acceleration * Time.deltaTime;
        Velocity.Truncate(MaxSpeed);
        transform.position += Velocity * Time.deltaTime;
        FixCollision();
    }