Some technical questions

  • Hi there,

    @Ashley I have few technical questions I'm hoping someone could answer for me:

    • What's best way to create an event sequencing? I tried setting a variable number, and then top condition for each sequence, and at the bottom, I had plain sub event adding 1 to sequencing variable, but seems like not all events are finished within same tick and so it ended up braking.

    Therefore: - Which of the following two actions is being completed the same tick as the action triggered and which one doesn't: Create object or Spawn object? Also Id like to know which other actions are being completed on the next tick?

    • Another question about sequencing is when the variable is being changed trough other set of events, it's not working, and I don't know why.

    Examples

    Not working: Every tick: add 1 to Variable, Variable grater then 6, set Variable to 0. If variable = 0, player is not moving along path, has player in sight: find path.

    Working: Every 0.0128 sec, player is not moving along path, has player in sight: find path.

    • When "repeat" and it has variable to check then add to the same variable, is it only checking that variable on each repeat or only on start of the loop?
    • What's best use of "While"?

    Thanks!

    M

  • the way I understand it is each tick (@ 60fps) has the potential to be executed up to 16ms after one another. But it's usually a lot less. the actual time varies from program to program and computer to computer.

    If you add 1 to a variable every tick, by the time you get to 6... approx 0.1 seconds of wall clock time will have passed. (this will vary a tad). You could use dt to make it more consistent between computers.

    if you are changing things in subevents I think they are done at the "end of the sheet", so you have to wait for the next tick for the results to update in the next top level event. Maybe this is causing a problem for you?

    EDIT: meant to say tick instead of Action on the first line

  • - When "repeat" and it has variable to check then add to the same variable, is it only checking that variable on each repeat or only on start of the loop?

    I think a Repeat only happens once in a tick. I think it's only a shortcut instead of you having to copy & paste the actions you want repeated.

  • Apart from wait, create object, and async. Actions , everything is done in order from top to bottom, an action is over before the next one.

    every tick add 1 to variable

    Variable greater than 6, set it to 0 . [...]

    If variable equal 0, [...] find path

    Be sure that the event to set it to 0 does not occur right before checking it, or more simply, use a time difference, it is more adapted to your use.

    create object and spawn another object are not done before the next top level event (aka the next event that is not a sub event of another one).

    For every async conditions, there is a trigger associated with it (local storage, ajax, etc..)

    If you check a value and do a loop, just see the order you did it, the loop comes first? Then it will check the value everytime, it is after? Then the oppositz, the value is checked before doing the loop.

    Sequencing can be problematic since the time between two events can vary (heck even if it was not the case, switching to a display of 120Hz would make it twice as short as a 60Hz display).

    Never used while loops as I prefer to use for loops, but maybe they are more flexible, be sure that it will not be endless.

  • jobel Aphrodite

    Thx for clarifying, though I still don't understand if created object through create or spawn is calculated same tick of not? I'm working on randomly generated map, and this is somewhat crucial i think as currently I'm getting some minor annoying bugs.

    Ps. The prototype version worked flawlessly, but the "clean and optimised version" broked! Same with version after. IRONY!

  • I still don't understand if created object through create or spawn is calculated same tick of not? I'm working on randomly generated map, and this is somewhat crucial i think as currently I'm getting some minor annoying bugs.

    I randomly generate the world map in my game as well. Although I only do it once at the beginning of the game. I do all the Creates/Spawns in OnStartOfLayout, then I refer to those objects in the main game loop. Do you have a similar set up?

  • Just a quick contribution - going back to the initial post, the problem seems to be about managing states and building a sequene of events i.e. logic blocks ; it sounds to be a perfect fit for a finite state machine. Building the logic as a FSM will make it easier to isolate each logic block, author transition logic, and manage state if you need to add/remove some

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Refeuh

    I'm not really great with terminology. Atm my state machines are like that

    If Var = 1 : do stuff, aad 1 to var

    If Var = 2 etc.

    And

    Every tick add 1 to Var2

    If Var2 = 1: do stuff

    if Var 2 = 2, etc

    Both have issues

    @jobel

    I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.

  • I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.

    yeah I'd have to see it, any chance you can make a minimal test capx just showing what you are trying to do?

  • > I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.

    >

    yeah I'd have to see it, any chance you can make a minimal test capx just showing what you are trying to do?

    Don't know. I'm using a bit of some unofficial plugins. But can send you trough message.

  • i recommend that you use this:

    each 0.2 sec + has sight towards player

    find path to player

    move along.

    instead of using var to check if it has some value. an setting it and stuff. now 0.2 sec is way slower then 0.016s (60hz)

    but it will work perfectly on any pc and won't be as taxing when doing it each 0.016s and won't calculate stuff with vars. also your vars thing won't work good when you go higher hz like 120hz screen.

  • I think you're confusing your own event bugs with the C2 event system. Construct 2 has a very strict ordering of events. All events are evaluated in top to bottom order (except for triggers, which fire in top to bottom order when something happens). Within those events the actions are run in top to bottom order. Everything happens synchronously (i.e. the same tick) except for long-running actions like AJAX's 'request' action, and these generally then fire a trigger when they complete. There are a very few rare exceptions (like the Pathfinding behavior's 'regenerate map' action takes a tick to take effect), but there are so few you can probably ignore them.

  • I think you're confusing your own event bugs with the C2 event system. Construct 2 has a very strict ordering of events. All events are evaluated in top to bottom order (except for triggers, which fire in top to bottom order when something happens). Within those events the actions are run in top to bottom order. Everything happens synchronously (i.e. the same tick) except for long-running actions like AJAX's 'request' action, and these generally then fire a trigger when they complete. There are a very few rare exceptions (like the Pathfinding behavior's 'regenerate map' action takes a tick to take effect), but there are so few you can probably ignore them.

    Thanks, could you list those exceptions please, because not knowing them, puts me back in the development sometimes by days. Also, I wonder if there is any way of selecting animation from within one of animation folders? For example "play animation: folder name/animation name" ?

    Thx

  • I really can't think of any other actions which finish the next tick, they are very rare IIRC. You can probably assume all other actions complete immediately.

    Animation folders are not exported - the runtime only identifies animations by their name.

  • I really can't think of any other actions which finish the next tick, they are very rare IIRC. You can probably assume all other actions complete immediately.

    Animation folders are not exported - the runtime only identifies animations by their name.

    Ok, thank you for clarification. You know, I'm using construct since CC Alpha 0.19 and always been stumbling on those little unusual quirks in both cc and c2. I do web programming professionally, wordpress php and such, so I'm not a newbie, but in construct it is bit different. In scenario where I have to generate random map, i have to create a lot of objects. It's working all of it now, but only after I've set events in the following way:

    Is Boo_D: Set Boo_D: False

    For each "Dudu" : Regenerate obstacle map

    Is Boo_C: Set Boo_C: False, Set Boo_D true

    Is Boo_B: Set Boo_B: False, Set Boo_C true

    --For each "DUDU" : do stuff

    Is Boo_A: Set Boo_A: False, Set Boo_B true

    -- for each floor: Spawn something called "DUDU"

    This is roughly as it goes, and obviously it works, giving some "breathing space" to all elements that are completed on the next tick, but sequences has to be placed in reverse.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)