time triggers

Get help using Construct 2

Post » Sat May 02, 2015 5:33 am

Hi!
I'm programming the Ai of a basic enemy in a sidescroller.

the enemy basically stays in a stand postion (looping a "stand" animation) until at a certain moment it triggers a jump animation and it attacks by jumping forward. then it lands and goes again to the stand anim.

everything works well but I can't find a way of having a perfect control of the moment the jump triggers.
The ideal way would be to have something triggering when the stand animation begins (after the jump). something like a "time marker". So, it would be like saying: once the marker is set wait X seconds and trigger jump. that way I can add some random seconds or control it easier and not rely on the frames of the stand animation.

I guess this is what TIMERS are for, but couldn't make it work. i found it on behaviors but don't have a clue how to use it.
B
5
S
1
Posts: 92
Reputation: 609

Post » Sat May 02, 2015 7:47 am

Hmm why not just use the built in Wait action?

As the event sheet is run the bots actions will pause at the Wait action for its duration then run rest of actions below (in the bots event.. all events on sheet run basically instantly 60 times a second) which will be the jump attack... use an instance variable to restart its conditions.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Sat May 02, 2015 6:29 pm

well, the wait works somehow but still brings a lot of problems

when the conditions are set the wait is triggered, followed by the attack. But sometimes the conditions change within the time of the wait and the attack triggers when it shouldn't. Let's say: the wait is tirggered (2 seconds) and then the enemy is killed triggering the DIE animation. then, as the wait was already triggered in different conditions the attack will play even when the enemy is in his dying animation. how can I solve this?
B
5
S
1
Posts: 92
Reputation: 609

Post » Sat May 02, 2015 6:39 pm

The timer behavior is easy to understand:

1) first you must start the timer with an action (start timer, which you can find under the object, that has the timer behavior); give the timer a name/tag.
2) then there is an event "on timer:", here you use the name you've given your timer and it will trigger when the timer is up

yeah... guess that's it.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sat May 02, 2015 7:54 pm

Let's say: the wait is tirggered (2 seconds) and then the enemy is killed triggering the DIE animation. then, as the wait was already triggered in different conditions the attack will play even when the enemy is in his dying animation. how can I solve this?


Yeah that would be a problem.

Only easy way I see around that while still using Wait this way would be to immediately "kill" destroy the instance when enemy is killed and instantly spawn an animation placeholder at its X,Y and run death animation off it.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Sat May 02, 2015 11:20 pm

maybe it's better having a couple variables for this action only. just to avoid having a new sprite only for the death animation.
B
5
S
1
Posts: 92
Reputation: 609

Post » Sat May 02, 2015 11:59 pm

Effectively. I tried and it worked. When the wait runs out it doesn't trigger the attack animation but sets a variable to 1.
then if that variable is 1 and the character is in the right animation it triggers the attack.
best way I could find.
B
5
S
1
Posts: 92
Reputation: 609

Post » Sun May 03, 2015 3:04 am

Simple but effective... one thing I love about Construct2 (and programming in general), there are a dozen or more ways to approach any problem.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333



Return to How do I....?

Who is online

Users browsing this forum: RobertMKD, tarek2 and 9 guests