Some Tips for Behavior Definition

ForeUI provides the flexibility to define actions for each element, we can use Event, Flow Control and Action to define the behavior as a flowchart. Here are some tips to help defining a clear and effective flowchart.

Don't Place Pause Action at the End

The Pause action can wait for a while before executing the subsequent actions. The correct understanding is that, Pause action can delay the subsequent actions. So if there is no action defined after the Pause action, the Pause action will not take effect, even if you place it in a loop, the Pause action will not take effect in next circle.

So Please don't place Pause action at the end, the table below show some examples:

Good Cases Bad Cases
  • Event
    • Pause 1000ms
    • Action A
  • Event
    • Action A
    • Pause 1000ms
  • Event
    • Action A
    • Pause 1000ms
    • Action B
  • Event
    • Action A
    • Action B
    • Pause 1000ms
  • Event
    • Loop
      • Pause 1000ms
      • Action A
  • Event
    • Loop
      • Action A
      • Pause 1000ms
  • Event
    • Loop
      • Action A
      • Pause 1000ms
      • Action B
  • Event
    • Loop
      • Action A
      • Action B
      • Pause 1000ms

Use Only One (or don't use) Pause Action In the Loop

Pause action is very useful when you want to implement an animation, we may want to place the Pause action in a loop. But please notice that if you place multiple Pause actions in one loop, the loop will not really work. This is a limitation of the Pause action implementation, and it seems to limit our design. Fortunately in most cases the "one Pause in one loop" can meet our requirement.

Good Case Bad Case
  • Event
    • Loop
      • Pause 1000ms
      • Action A
      • Action B
      • Action C
  • Event
    • Loop
      • Action A
      • Pause 1000ms
      • Action B
      • Pause 1000ms
      • Action C

If you really need the case listed as bad case above, you can change it to this structure:

Case to Workaround
  • Event
    • Loop
      • Pause 1000ms
      • Switch
        • Case A: Action A
        • Case B: Action B
        • Case C: Action C

With this structure, you can perform one action in one circle, and the interval between circles will be 1 second.

From V2.00, the loop support delay itself, so you don't need to use Pause action in loop.

Make Good Use of Copy and Paste

The copy and paste for behavior editor is supported from V1.70, you can right click the item in the behavior tree and perform cut, copy or paste. You can do the copy and paste cross events, or even cross elements. That will save you a lot of time to define similar behavior for multiple elements.

You can also use drag and drop to move or copy items of behavior tree.