AI sprite change anim based on trajectory

Get help using Construct 2

Post » Wed May 09, 2012 10:48 am

I know how to change the player sprite/animation based on whether they are moving up, down, or left and right to imply movement. What I can't figure out is how to make an entity not controlled by the player do the same. The enemy doesn't have a "patrol" per se. He kind of wanders in a random fashion bouncing off solids. But every few seconds I have it reset it's angle to face the player, giving a vaguely "zombie like AI pathfinding" (also repositions angle based on "loud" elements caused by the player...etc. Anyways, I can think out the math but can't figure out how to make construct agree with me :)

If your x speed (absolute) is greater than your y speed (absolute) then you are moving predominantly on the x axis or left/right.

If your x speed is negative you are heading left = play "walk_left" anim

or

If your y speed (absolute) is greater than your x speed (absolute) then you are moving predominantly on the y axis.

If your Y speed is positive you are heading up = play "walk_up" anim

and so forth. But I can't find the ability to compare x and y speeds so I can start making this determination. Am I over or underthinking this?
B
11
S
1
Posts: 44
Reputation: 1,095

Post » Wed May 09, 2012 11:34 am

Hey Tporter,

Have you looked at using the "Is between angle" to play the right animation instead? That should cut a lot of the math work anyway :)GenkiGenga2012-05-09 11:34:26
ImageImage
B
73
S
16
G
6
Posts: 1,039
Reputation: 10,475

Post » Wed May 09, 2012 6:09 pm

yeah, Is between angle works pretty well for switching now. I'm basically trying to get the AI and animation behavior of say the guards in Zelda: LTTP. They kinda do their own thing and upon drawing aggro start approaching the player, of course I don't need my guys to move diagonally. Thanks for the idea. I knew there was a quality shortcut.
B
11
S
1
Posts: 44
Reputation: 1,095


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 28 guests