Run actions in sequence.

I have several different actions (as in animated action sequence editor) on a character, which I want to repeat continuously one after the other. For example, I might have four actions:

  1. Walk north 4 paces
  2. Walk east 10 paces
  3. Walk south 4 paces
  4. Walk wesr 10paces.

I want the character to cycle through these actions in sequence like 1 - 2 - 3 - 4 - 1 - 2 - 3 - 4 etc.

What’s the most efficient way of going about this? I would prefer logic brick solutions as opposed to python scripts please.

Thanks for reading :slight_smile:

You can use the “Frame Property” field of an Action actuator to store the current frame of an animation.
Once you know the frame you can derive logic conditions that are triggered when an animation ends - or is in progress or started.
For example, if you know that AnimationA ends at frame 100, if you store the frame in a “CurrentFrame” game property you can add a sensor to say “when CurrentFrame is 100 -> execute the actuator for AnimationB”.
If the timelines of your animations overlaps (multiple animations that starts at frame 0 for example) you need a way to differentiate equal frame values, a thing you can do with states or game properties.

You can use a logic for loop,

Check this example, it’s using a logic for loop to do rotations, /uploads/default/original/4X/1/9/f/19f822f574974defc8d4abd3b81360deb791cac1.blendd=1385315399

You should be able to have a interval property sensor advance a property that you use to sequence the actions,

You can use states to process the sequence.
Each state is responsible to play exactly one action.

This requires that you can sense when an action ends. The property method as mentioned above is pretty solid but means you need to define the end of the action twice (first in the action actuator a second time in the property sensor).

Another way is you use the actuator sensor. It was introduce to do exactly this - sense when an actuator deactivates. Just take into account - the sensor is deactivated right from the beginning ;).

I hope this is the hint you need.

Thanks for your responses.

I’ve got something going now using the “property” method (see attached file). I’m really pleased that the properties are local to the character (as opposed to global variables) because this means the technique can be used to make a whole array of duplicated space invaders work with slightly different offsets (as an example).

Thanks again.

action_cycle_example.blend (544 KB)

There is an odd problem though. If you play the above file, the pink bot (aka Fiona) does about two cycles of the movement, then starts behaving erratically. I’d put in some boolean values for “is moving” to prevent issues with the user hitting the “start” key trigger once already moving. Any idea what’s going on with my wiring to cause this?

I’m still not sure why this works better, but in that last file if I split the previous OR into two separate single ANDs, the pink cube “Fiona” doesn’t play up anymore.

action_cycle_example02.blend (548 KB)

Solved then, but if anyone has and explanation of why the last file went bad, please let me know.