regenerate obstacles map

Discussion and feedback on Construct 2

Post » Mon Aug 12, 2013 2:27 pm

Hi,
my game behaves like this

1. click button
2. objects destroyed
3. user finds path to exit

What happens is that between 2 and 3 i have to regenerate obstacles map since layout has changed.

The events are

> regenerate obstacles map and then
> findpath

The only way i made this to work was to introduce a delay between regenerate path and findpath. Like wait 1 seconds.

Is this the only way to work ? is there a event that would trigger when regenerate obstacles ends calculations ?

Thanks
Bruno
B
5
Posts: 17
Reputation: 359

Post » Tue Sep 03, 2013 11:50 am

I got the same problem.

Is there any solution?
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Tue Sep 03, 2013 12:42 pm

It takes one tick for the pathfinding map to be regenerated. So the correct solution is to wait a small amount of time before finding a new path.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684

Post » Tue Sep 03, 2013 12:47 pm

Thanks.

Is there any formula or direct "wait for X ticks" command?
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Sat Sep 07, 2013 12:50 am

You may have figured this out already but...

Just use a variable and add one to it each tick. Then reset it to 0 after you do something. Then check if it is greater than an amount (# of ticks) since you reset it to 0. Pretty simple. You can also use it inversely as well (Lag). You say: each tick, if Lag > 0, Lag = Lag-1

I'm making a fighting game so this is a great way to detect whether a combo is dropped, or a universal way to add a set amount of lag to stuff. For example, if I do an attack that has 40 frames of lag, I can set Lag to 40. Then on all my actions that can't be done if you are lagging, you just put a conditional of "if Lag <= 0" pretty simple. Usually, when Lag goes from being > 0 to being = 0 I will zero ANOTHER variable called FramesPassed. This variable keeps track of the number of frames since the END OF LAG. This is also useful, for example... if you jump but release the jump button quickly enough after the jump registers (and before lag ends or a certain few frames after Lag ends), you can have it perform a short hop (lower jump) instead of a full jump. There are plenty of ways to utilize this...

Similarly if you allow cancelling at the beginning and end of a move into certain other moves you can use variables that keep track of frames since the start of the move.

Basically in my game for example, I keep track of:
Frames of Lag
Frames since Lag ended
Frames since the start of a move

These allow me to have frame accurate control over my game (unlike many games, serious fighting games require constant framerates and timings for things)Acryte2013-09-07 00:52:15
B
9
Posts: 12
Reputation: 477


Return to Construct 2 General

Who is online

Users browsing this forum: fearfulelephants and 15 guests