Question about new AI module #468
-
Hi, I have a question about the new AI module. I tried to add it to my project and replace the file approach. I think, that way I can avoid certain reflection stuff and the game would then run in the browser using TeaVM. However, I am not 100% sure how to translate my tree to the KTX DSL when it comes to conditions. I have following file:
I tried to translate it to the following: behaviorTree<AIEntity> {
`object` = AIEntity(entity, this@onAdd, inject("GameStage"))
selector {
sequence {
guard = semaphoreGuard {
add(IsEnemyNearby())
add(CanAttack(range = 1f))
}
add(AttackTask())
waitLeaf(UniformFloatDistribution(1.25f, 2.1f))
}
sequence {
guard = dynamicGuardSelector {
add(IsEnemyNearby())
}
add(MoveTask(2f))
}
sequence {
random(ConstantFloatDistribution(0.25f))
add(IdleTask(UniformFloatDistribution(2f, 3.5f)))
}
add(WanderTask(6f))
}
} The guard stuff does not compile. How do I provide the conditions? Or how would you translate my example file? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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))
}
} Interestingly enough the guards of the attack and move sequence are not showing up as guards in the tree when loading from the file. Don't know why to be honest. Anyway, everything seems to work now! One thing: would be nice if we can use |
Beta Was this translation helpful? Give feedback.
-
Also works now in the browser with TeaVM: https://quillraven.github.io/MysticWoods/ Amazing stuff! :) |
Beta Was this translation helpful? Give feedback.
I debugged the tree when loading it from the file and this gave me a clue how to use the DSL:
Interest…