Exemple #1
0
    public override void _Process(float delta)
    {
        if (_health <= 0)
        {
            ((game)this.GetNode("../..")).EnemyDead();
            QueueFree();
            return;
        }
        KinematicBody2D player            = (KinematicBody2D)GetParent().GetNode("player");
        Vector2         directionToPlayer = (player.Position - this.Position).Normalized();

        MoveAndSlide(speed * directionToPlayer);

        ColorRect healthRect = (ColorRect)GetNode("health");

        healthRect.SetSize(new Vector2(_health, healthRect.GetSize().y));
    }