Remember picked objects having the same effect as Forget

This forum is currently in read-only mode.
From the Asset Store
Try to remember the sequence of moving pumpkins. Reproduce it according to your memory.
  • Hi,

    I set up a function (DestroyBullet) to destroy instances of bullets (shot by the player). The function simply destroy the bullet object and spawn an explosion effect (an animated sprite, fading).

    I used a similar function (exactly the same events used) when I destroy dead ennemies. For those, I used the option "Remember picked objects", so the function only destroy the one effectly dead, and it worked perfectly.

    When I use the function on my bullets (they are destroyed when hitting a solid object or an enemy), with the exact same options, it doesn't, every time, ALL instances of bullet are destroyed, no matter what I use (remember or forget picked object).

    If I copy/paste the two events of the function in the conditions that would normally trigger DestroyBullet (instead of actually calling the function), it work perfectly.

    Have I did something wrong ?

  • Is your bullet object global?

  • Nop, neither the bullet nor the ennemies are global.

    Got quite a similar problem today, I created a function with one parameter.

    The parameter is an amount of damage, choose randomly at the call of the function, the function substract those damage from the ennemy and add it to the score.

    When I used "forget picked object", all enemy where damaged together. So killing an enemy will make all of them blow up.

    When I use "remembered picked object", sometimes only one dies, sometimes all of them, sometimes it seems they take only a part of the damage (may be it's due to the time when they were spawned).

    I think I don't understand at all how it's suppose to work.

    Is there a way to access a specific object in python ? I know that the "Enemy" variable works as a list, but how can I retrieve the exact enemy (well, the index) concerned by the event ?

  • It's hard to tell without a cap, but I guess it is a picking problem, not the function object working incorrect.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The two events picking bullets are :

    • On collision between Bullet and Enemy
    • On collision between Bullet and Solid

    Is that the problems ?

    I'll upload the cap at the occasion, but it's quite a mess as it's my first project and I already got a lot of event and pieces of scripts.

  • Are you using call function after delay?

  • newt's question plus:

    "may be it's due to the time when they were spawned"

    Are you spawning them in the same tick, when trying to access a pv of the enemies? Sprites are created at the very end of a frame. Maybe that is causing problems in some situations, because the function call takes place the moment you call it.

  • Are you using call function after delay?

    Nop, simple call function.

    newt's question plus:

    "may be it's due to the time when they were spawned"

    Are you spawning them in the same tick, when trying to access a pv of the enemies? Sprites are created at the very end of a frame. Maybe that is causing problems in some situations, because the function call takes place the moment you call it.

    Enemies are spawned randomly every x milliseconds, it's not tick based i think.

    Bullet are spawned every 100 ms if mouse button is down.

  • Enemies are spawned randomly every x milliseconds, it's not tick based i think.

    Bullet are spawned every 100 ms if mouse button is down.

    I still think that this is the problem when picking the objects. You have to make sure the sprites are already created before you can safely access them (e.g. to access a pv of sprite x, you need to wait at least one frame after sprite x was spawned)

    If I recall right, the timing conditions are dependent of the frames whereas the function object has its own timing. That could lead to situations where your order of events is right, but they are still executed in another order. When spawning and accessing a sprite meet in the same frame it does simply not work, without an error message or debugger salience.

    I can't help with python, but I used a trick for the functions (delaying the access to a sprite by at least 1 tick) to avoid that problem in my auto zoom engine. Maybe you can integrate and adapt it. (you find the events of interest in "Camera Control":"HighLevelFunctions":"Camera Creation/Deletion" plus event 14 of "Camera Control":"LowLevelFunctions")

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