How do I do random sprite animations [Set AI]

Get help using Construct 2

Post » Tue Apr 12, 2016 12:15 pm

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!
B
49
S
33
G
19
Posts: 59
Reputation: 14,244

Post » Tue Apr 12, 2016 1:49 pm

Hello, i dont really know but is it what u was looking for ?
https://www.dropbox.com/s/pj02fabhmh549 ... .capx?dl=0
Last edited by Snowmany on Mon Dec 12, 2016 11:07 pm, edited 1 time in total.
B
28
S
12
G
3
Posts: 6
Reputation: 3,685

Post » Wed Apr 13, 2016 5:35 pm

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"
B
83
S
40
G
15
Posts: 993
Reputation: 16,909


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 1 guest