0 Favourites

regenerate obstacles map

  • 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

  • I got the same problem.

    Is there any solution?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • Thanks.

    Is there any formula or direct "wait for X ticks" command?

  • 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)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
81 11,908
LaurenceBedford's avatar
LaurenceBedford
Unread hot topic
0 Favourites
[PLUGIN] Google Map
118 34,689
eryson27's avatar
eryson27
Unread hot topic
85 16,425
gaminslab's avatar
gaminslab