Example #1
0
    protected void Update()
    {
        Vector2 steering = Vector2.zero;

        foreach (var steeringBehaviour in steeringBehaviours)
        {
            steering += steeringBehaviour.GetSteering();
        }

        if (avoidObstacles && (avoider != null))
        {
            steering = avoider.AvoidObstacles(steering);
        }

        movement.Move(steering);
    }
Example #2
0
    protected void Update()
    {
        Vector2 steering = Vector2.zero;

        foreach (var steeringBehaviour in steeringBehaviours)
        {
            steering += steeringBehaviour.GetSteering();
        }

        // TO DO: Make this properly polymorphic (i.e. make a parent "ObstacleAvoider" class with subclasses for fly and frog)
        if (avoidObstacles)
        {
            if (avoider != null)
            {
                steering = avoider.AvoidObstacles(steering);
            }
            if (avoiderFrog != null)
            {
                steering = avoiderFrog.AvoidObstacles(steering);
            }
        }

        movement.Move(steering);
    }