Possible picking bug ?

0 favourites
  • 4 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hello,

    Just want to be sure, i have been able to reproduce a strange behavior with functions and picking.

    I have two functions: One to create a sprite with ID (custom instance property) set to 3 and one to actually pick that sprite (based on ID = 3).

    I am calling theses both functions in the event "On layout start". I though it would work.. i was expecting the picking function to pick the instance where the ID = 3 but the function that pick the sprite doesn't pick the sprite as if there was nothing to be picked but the sprite with the ID 3 got created in the first function.

    But if i put two events "On layout start" and call the create function on one and the pick function on the other it work well!

    I can't post a sample right now since i am not at home. But you should get the idea.. is this a normal behavior ? and why ?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, it's working by designed, as far as I understand.

    Construct 2 always call the events from top to down, and creating the object in the same event where you're trying to pick it is not always possible because the runtime will try to create and pick the object at the same exactly time.

    Instead, picking it right after, by using a new branch of events, is always possible and a good practice.

  • Yeah but creating and picking are not in the same event. Creating are in a function call and picking in another function call (so both in different events). But both function call are in the same event.. but it is the same thing as putting them in the same event ?

  • Yeah but creating and picking are not in the same event. Creating are in a function call and picking in another function call (so both in different events). But both function call are in the same event.. but it is the same thing as putting them in the same event ?

    Yes, they are in the same event, but not in the same action.

    If they run in the same conditional level, they are in the same event, excluding sub-events, because when you run a sub-event, it will run top to down again and make the priority as a sequence.

    For example.

    -> Conditional: Every 5 seconds;

    --> If object1 is NOT ON the screen:

    ---> Create object1 at X, Y;

    ---> Set object1 ID = 1;

    --> Else

    ---> Destroy object1 with ID = 1;

    it will run the code, create the object1, setup its ID = 1 and then destroy it in the same second;

    Instead, you want keep it for 5 seconds and re-check it to destroy and create it again in another place, so:

    -> Conditional: Every 5 seconds;

    --> If object1 is ON the screen:

    ---> Destroy object1 with ID = 1;

    --> Else

    ---> Create object1 at X, Y;

    ---> Set object1 ID = 1;

    Edited:

    I missed to say, sometimes, it's handful to use the action "wait=0,0" right after an action where you want make sure the order will be follow, inside the same conditional.

    For example:

    -> Every 5 sec;

    --> Destroy object1 with Id = 1;

    --> Wait 0,0;

    --> Create object1 at X, Y;

    --> Set ID = 1;

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