AngryAnt / Behave-release

The Behave project is a system for designing, integrating and running behaviour logic using Behaviour Trees for simulated characters in unity projects. NOTE: This project relates to Behave 1. For Behave 2 support and information, please use the AngryAnt community at http://community.angryant.com
http://angryant.com/behave
34 stars 6 forks source link

InitAction not being called after reset #30

Closed ricardojmendez closed 12 years ago

ricardojmendez commented 12 years ago

I have a behavior tree on Behave 1.3.1 where Behave might be called in the middle of a Move action (since it might be interrupted by the agent being attacked).

Suppose the creature gets stunned while moving, which invokes a behaviorTree.Reset(). It will eventually reach the Move action dagain. However, the time that Move is ticked after the Reset() the InitMoveAction is not called as it should, so it skips any initialization that you meant to do.

ricardojmendez commented 12 years ago

This issue persists on 1.4

AngryAnt commented 12 years ago

No repro seen since latest 1.4 fixes. Closing as fixed.

ricardojmendez commented 12 years ago

I've just found this issue on 1.4. I'm logging both InitMove and TickMove actions on a tree.

Domo-DomoSpawner-0 InitMove 1.844796 UnityEngine.Debug:Log(Object) VehicleCreature:InitMoveItAction(Tree) (at Assets/PapercraftCode/Agents/Base/VehicleCreature.cs:106) BTCreaturesC1T0:TickAgent(IAgent, Int32, Boolean, Tree, String, Single, Object)

Domo-DomoSpawner-0 Move 1.844796 Running UnityEngine.Debug:Log(Object) VehicleCreature:TickMoveItAction(Tree) (at Assets/PapercraftCode/Agents/Base/VehicleCreature.cs:118) BTCreaturesC1T0:TickAgent(IAgent, Int32, Boolean, Tree, String, Single, Object)

Domo-DomoSpawner-0 Move 1.880821 Running UnityEngine.Debug:Log(Object) VehicleCreature:TickMoveItAction(Tree) (at Assets/PapercraftCode/Agents/Base/VehicleCreature.cs:118) BTCreaturesC1T0:TickAgent(IAgent, Int32, Boolean, Tree, String, Single, Object)

[...]

Domo-DomoSpawner-0 Move 3.521052 Running UnityEngine.Debug:Log(Object) VehicleCreature:TickMoveItAction(Tree) (at Assets/PapercraftCode/Agents/Base/VehicleCreature.cs:118) BTCreaturesC1T0:TickAgent(IAgent, Int32, Boolean, Tree, String, Single, Object)

Then the tree gets reset. Some time later it ends up on the Move action again, and the next one logged is:

Domo-DomoSpawner-0 Move 10.66101 Running UnityEngine.Debug:Log(Object) VehicleCreature:TickMoveItAction(Tree) (at Assets/PapercraftCode/Agents/Base/VehicleCreature.cs:118) BTCreaturesC1T0:TickAgent(IAgent, Int32, Boolean, Tree, String, Single, Object)

With no InitMove action being logged.

ricardojmendez commented 12 years ago

Found it - this happens if Reset is called from within a running action handler.

AngryAnt commented 12 years ago

Finally stomped on this nasty bugger. The Running return value was key. 1.5 holds a fix addressing this directly.