Parallel task repeats other tasks.
lukz opened this issue · comments
Is it intended for parallel task to repeat all tasks until all tasks return success condition or one return fail condition (depending on policy)?
I want to make a monster which starts to move and at the same time shoot 5 times. Movement can take a lot longer than shooting. No matter how I construct this parallel task monster is shooting constantly until movement task is finished or stop moving after finishing shooting.
To demonstrate:
root
sequence
parallel policy:"sequence"
sequence
wait seconds:0.3f
log text:"TASK1"
log text:"TASK2"
log text:"END"
wait seconds:10
(Log task returns SUCCESS instantly after execution)
This is output:
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK2
GDXAI: TASK1
GDXAI: TASK2
GDXAI: END
In short Yes, parallel task will repeat all tasks (it restarts completed tasks).
For your case, you need an extra task to know when to stop shooting (when not moving). It could be something like this :
root
sequence
parallel policy:"sequence"
sequence
wait seconds:0.3f
log text:"TASK1 (move finished)"
sequence
repeat times:5
log text:"TASK2 (shoot once)"
waitIdleState
log text:"END"
wait seconds:10
where "waitIdleState" is returning :
- SUCCESS when monster is not moving
- RUNNING otherwise.
@mgsx-dev this seems to break whole idea of reusing tasks in BT without additional code. I guess I'll just replace parallel task with my own one ;)