0 Favourites

How do I do random sprite animations [Set AI]

  • How do some of you set your AI with the animations...

    I want my AI to do random animations ever x seconds.

    Like first the sprite starts walking...then it may fall asleep or start eating

    then I want to loop these animations...Sprite starts walking again then falls to sleep again blah blah

    So how would I go about doing this?

    Please post .capx if you can!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Hello, i dont really know but is it what u was looking for ?

  • Ideally you would set up a bunch of different "states" for your character. and assign him a variable called "state".

    if: state = "walking" -> do walking animations etc.

    and make seperate conditions for each state he might get into.

    this allows you to group a number of actions together and he will be able to do lots of different things depending on the movment required and which animation needs to be played.

    then one simple way to pick which state he'd go into randomly is

    every X seconds - set enemy.state to = choose ['walk', 'sleep', 'run', 'pushups']

    so it will randomly throw him into a new state every x seconds.

    or base it on other conditions like.

    while enemy.state = "walk" -> every 1 second, add 1 to enemy.walkingsteps.

    if enemy.walkingsteps > 100 - set enemy.state to "sleep"

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)