"Wait" and timescale issues

Get help using Construct 2

Post » Thu Feb 21, 2013 9:29 pm

I'm trying to create an enemy behavior where the enemy will freeze momentarily if they are hit by one of the player's bullets.

Though setting the enemy's "timescale" to 0 works to some degree, I have run into a major unforseen issue due to how my enemy is set up. The enemy's behavior involves waiting for a couple of seconds, firing a bullet, then firing a second bullet, and then restarting the process. Simple enough. To accomplish this, I'm using the System command "wait" to determine the amount of time between enemy actions. (seen below)



The problem is this: Setting the enemy's timescale to 0 does not pause these specific System Waits. So if there is a wait of 2 seconds and I shoot the enemy at 0.5 seconds, this Wait will continue to count even though the enemy is supposed to be frozen. So once the enemy is unfrozen, their next action will occur immediately instead of 1.5 seconds later.

I'm going to attempt my own solutions and I'll post here if I come up with something that works really well. It may just involve completely changing the way I write enemy behaviors (maybe it's not a good idea to be using Waits for this sort of thing). But I'm curious as to how other people have dealt with these sorts of timing issues.Madguy2013-02-21 21:30:53
(M.A.D. are my initials. I'm not the least bit angry, really!)
@madguy90
B
11
S
4
Posts: 41
Reputation: 1,666

Post » Thu Feb 21, 2013 10:52 pm

A good way is use delta time to set your "waits" and "stuns"

set your enemy/enemies an instance variable,lets call it "pause"

>enemy variable "pause" equal to 0......do enemy stuff (normal behaviour so have it set at that to begin)(start movement)

ok now if your enemy is hit

>enemy on collision with player shot....set variable "pause" to 1(stop movement)

>enemy fires for first time>...set variable "pause" to 3(stop movement)

>enemy "pause" equals 2>.....fire second shot(stop movement)

now this is the waiting bit

>eneny variable pause is greater than 0...enemy subtract 0.5*dt from "pause"

because after firing it is set to 3 it will cout down creating a pause then hit 2 and fire again

using bullet behaviour just set the bullet speed to 0 to stop and back to default when you want movement again...

You can play about with the 0.5*dt and numbers to set your wait time.

hope that helps...ps: using wait is not the best way as i think you realised....Pixel perfick2013-02-21 23:04:34
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Thu Feb 21, 2013 11:46 pm

That was a really good idea. I changed my implementation to use this method.. works like a charm. Many thanks.
(M.A.D. are my initials. I'm not the least bit angry, really!)
@madguy90
B
11
S
4
Posts: 41
Reputation: 1,666

Post » Thu Feb 21, 2013 11:55 pm

Glad you got it working,happy to help!
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests