Skip to content

Question about new AI module #468

Answered by Quillraven
Quillraven asked this question in Q&A
Discussion options

You must be logged in to vote

I debugged the tree when loading it from the file and this gave me a clue how to use the DSL:

behaviorTree {
    `object` = AIEntity(entity, this@onAdd, inject("GameStage"))

    selector {
        sequence {
            guard = GdxAiSequence(IsEnemyNearby(), CanAttack(range = 1f))
            add(AttackTask())
            waitLeaf(UniformFloatDistribution(1.25f, 2.1f))
        }

        sequence {
            guard = GdxAiSequence(IsEnemyNearby())
            add(MoveTask(2f))
        }

        sequence {
            guard = GdxAiRandom(ConstantFloatDistribution(0.25f))
            add(IdleTask(UniformFloatDistribution(2f, 3.5f)))
        }

        add(WanderTask(6f))
    }
}

Interest…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@czyzby
Comment options

Answer selected by Quillraven
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants