Object picking has stopped working correctly

This forum is currently in read-only mode.
From the Asset Store
_______ Huge collection of metal fixtures ________
  • I've been working on this game off and on for some months now. Now all of a sudden Many of the object picking has stopped working correctly

    Such events as this.

    On collision between sword and enemy ; Subtract from hp

    It causes all enemies to lose health.

    Why is this happening???

  • Whats picked first?

    Sword or enemy?

  • Whats picked first?

    Sword or enemy?

    Tried it both ways with no success.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In these scenarios it's best to post a .CAP file (uploaded to mediafire or something), or post screencaps of the event sheet in question.

  • In these scenarios it's best to post a .CAP file (uploaded to mediafire or something), or post screencaps of the event sheet in question.

    I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work.

    I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

    The event basically calls a random value then checks what item it should drop.

    I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

    I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).

  • I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work.

    That's absolutely ok and understandable. But most then create a new example cap that shows the error. Helps a lot when several aspects come together that you are not aware of when trying to help.

    I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

    The event basically calls a random value then checks what item it should drop.

    I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

    I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).

    This for example: I don't see the exact event. Basically, using 'else' can explain it.

    When it comes to the action destroy, 'else' seems to not pick anything (not picking the opposite as one would expect). And if nothing is picked, Construct always refers to all instances.

    Enemy's health <= 0 and Already dropped = 0 -> do something
    else -> destroy[/code:242yuwix]
    Such a construct does not pick anything on the 'else' part and therefore destroy any enemy
    
    [code:242yuwix]Enemy's health <= 0
         Already dropped = 0 -> do something
         else and Pick by enemy('health') <= 0 -> destroy[/code:242yuwix]
    Such a construct would first make sure that any enemy with health <= 0 will drop and then destroy any enemy with health <= 0
    
    But as I said, I don't see the exact events, so I don't know why 'else' is used. It isn't needed to let them drop and destroy them. This can be done in one step.
  • > I dont feel comfortable to post the cap. I've been working on this game for a few months now and would not want someone coming along and steal my work.

    >

    That's absolutely ok and understandable. But most then create a new example cap that shows the error. Helps a lot when several aspects come together that you are not aware of when trying to help.

    >

    > I have found the Event that's causing the problem When an enemy=<0 a set of events is run to check if the enemy drops an item then destroys the enemy.

    >

    > The event basically calls a random value then checks what item it should drop.

    >

    > I haven't implemented this fully in the game (I also would like to reedit this event) so the only true option right now is the else at the end that just destroys the enemy. This is whats causing all the enemies to destroy themselves.

    >

    > I'm going to rework the event group to fix it. Although this does not explain the abnormality(else destroying all objects).

    >

    This for example: I don't see the exact event. Basically, using 'else' can explain it.

    When it comes to the action destroy, 'else' seems to not pick anything (not picking the opposite as one would expect). And if nothing is picked, Construct always refers to all instances.

    Enemy's health <= 0 and Already dropped = 0 -> do something
    else -> destroy[/code:2u5856s9]
    Such a construct does not pick anything on the 'else' part and therefore destroy any enemy
    
    [code:2u5856s9]Enemy's health <= 0
         Already dropped = 0 -> do something
         else and Pick by enemy('health') <= 0 -> destroy[/code:2u5856s9]
    Such a construct would first make sure that any enemy with health <= 0 will drop and then destroy any enemy with health <= 0
    
    But as I said, I don't see the exact events, so I don't know why 'else' is used. It isn't needed to let them drop and destroy them. This can be done in one step.
    

    The event group is basically, this(its a bit bigger but just repeating events)

    Enemy hp <= 0 -> set global variable drop to random(100)
         value drop is between 0 and drop_array (1,1) ->  destroy enemy
         value drop is between drop_array (1,1) and drop_array (1,2) -> create item at (enemy.x, enemy.y), destroy enemy
         value drop is between drop_array (1,2) and drop_array (1,3) -> create item2 at (enemy.x, enemy.y), destroy enemy
         else -> destroy enemy[/code:2u5856s9]
    The concept is that it draws a random number and then uses a drop table to check what drops, 0-x = nothing 
    x-y = item
    y-z = item2
    the else is really there in case something goes wrong.
    
    Like i said before this system was limited and didn't have everything I wanted in it so I'm just going to redo it.
  • A couple things.

    Once hp goes to zero your continuously setting your global to random(100) in this scenario.

    "Trigger Once" will fix that, as long as that sprite is still picked in the variable comparison in the sub events.

    Also there is no "value between" expression so there could be some mix up there as well.

    ......But, and its a big but, the else is definitely your biggest issue.

    Just so you know, you can still reference a destroyed object while still in the same event.

    Given that little tidbit, I'd suggest adding a "drop" variable to the enemy object, instead of using a global.

  • A couple things.

    Once hp goes to zero your continuously setting your global to random(100) in this scenario.

    "Trigger Once" will fix that, as long as that sprite is still picked in the variable comparison in the sub events.

    Also there is no "value between" expression so there could be some mix up there as well.

    ......But, and its a big but, the else is definitely your biggest issue.

    Just so you know, you can still reference a destroyed object while still in the same event.

    Given that little tidbit, I'd suggest adding a "drop" variable to the enemy object, instead of using a global.

    The event group was designed to always destroy the enemy object no matter what. (hence why Iput a else statement into it to prevent the exact situation you mentioned. ) this way any enemy with 0 hp will only stay for one tick.

    Also, there IS a value between condition its "Number in between..." In system

    (highlighted in blue)

  • That's correct, but system comparisons do not pick, or place objects into the selected objects list.

    For example if you were to compare the enemy's private variable that way it would not pick that instance.

    Same goes for system compare, or system evaluate.

    Anyways, just pointing out the subtleties that might lead to more errors, like the fact that else doesn't take picked objects into account.

    In fact once the else affects an object, and is triggered, including any held in subevents, all events that excluded it beforehand are thrown out the window.

    http://dl.dropbox.com/u/666516/ohshi.cap

  • That's correct, but system comparisons do not pick, or place objects into the selected objects list.

    For example if you were to compare the enemy's private variable that way it would not pick that instance.

    Same goes for system compare, or system evaluate.

    Anyways, just pointing out the subtleties that might lead to more errors, like the fact that else doesn't take picked objects into account.

    In fact once the else affects an object, and is triggered, including any held in subevents, all events that excluded it beforehand are thrown out the window.

    http://dl.dropbox.com/u/666516/ohshi.cap

    Your .cap example does show what I was originally commenting about. Where i would assume when sprite is picked in event 2 it would also use the picked sprite for event 4(something it Should do imo.)

    Long story short.(aka what I learned)

    Else doesn't use picks.

    Objects are destroyed at the end of ticks.

    thanks for the help.

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