How do I make a single object act differently than the other of the same type?

  • Hello, i'm making a game with several object, and i made one who rotates (box). At the start of the layer this object spawn 6 other object named "cristal" (rotating too). And i want to make them too disapear when i destroy a the box. But, the problem is that after few second, a new box appear with the same cristals. But i dont want them too disapear when i destroy the first box.

    Do you have any idea of how i can do that ?

  • You give the box an instance variable, some kind of ID number. Then when it spawns the crystal you assign this ID to the crystal also as an instance variable. So box.ID=crystal.ID, they will be the same number. Then when box dies, you say pick all crystal where crystal.ID=box.ID and destroy crystal.

  • You give the box an instance variable, some kind of ID number. Then when it spawns the crystal you assign this ID to the crystal also as an instance variable. So box.ID=crystal.ID, they will be the same number. Then when box dies, you say pick all crystal where crystal.ID=box.ID and destroy crystal.

    Thank you for your answer ^^ Ye it could have work, but the problem is that these boxes have the same base even sheet, and that makes them change the id every time another one spawn, so to kill the first cristal im obligated to destroy the third box. Because she sets the variable to it id .

  • If you do the logic in the correct order it should be fine :

    Box : spawn crystal. set cystal.variable to box.variable

    On box destroyed : pick all crystals where crystal.variable=box.variable, destroy crystal

  • If you do the logic in the correct order it should be fine :

    Box : spawn crystal. set cystal.variable to box.variable

    On box destroyed : pick all crystals where crystal.variable=box.variable, destroy crystal

    How do i pick all cristal with the variable ? i mean the pathway ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should actually provide your project for us to see how you implemented things.

    Indicate clearly what you are willing to do in your game (step by step), what you expect the code you have set in your project to do, what you experience it actually does (and how it is different from what you expect).

    Then it will be easier to provide you accurate answers to your issue.

  • You should actually provide your project for us to see how you implemented things.

    Indicate clearly what you are willing to do in your game (step by step), what you expect the code you have set in your project to do, what you experience it actually does (and how it is different from what you expect).

    Then it will be easier to provide you accurate answers to your issue.

    Well, i can only give you the link for the game, its in the 2 lvl. And there is the images of the even sheet and the in game "boxes" and "cristals".

    emperorparadox.itch.io/horizon

  • So directly under the spawn missile action, you set missile.ID to enemiround.ID

    Then when enemiround destroyed, you say system pick by evaluate : missile object, missile.ID=enemiround.ID, destroy missile.

  • So directly under the spawn missile action, you set missile.ID to enemiround.ID

    Then when enemiround destroyed, you say system pick by evaluate : missile object, missile.ID=enemiround.ID, destroy missile.

    Okay, hum i put that like this, the first box work perfectly ,when destroyed it destroyed it cristals, but the other box are just destroy but keep the cristals.

  • Don't use IID. Use an instance variable on the enemiround object. IID can change as you destroy one so that's not helpful.

  • Don't use IID. Use an instance variable on the enemiround object. IID can change as you destroy one so that's not helpful.

    yes, but u said too use some "ID" but i dont knwo how to change it. Can u maybe make an event sheet example ?

  • Emp, here’s a page on instance variables: https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/objects/instance-variables

    Edit: updated url

    I saw the example, but the problem is that cristal round arent on the layer, they are spawned by another sprite. So when a second one appears it change the variable for all other cristal round and cristal. But in your point of view, ill need to spawn all the box at the beginning ?

  • Ah I missed out something there which may have confused you. You need a global variable that acts like a counter, then when you create enemiround object you set enemiround.variable to global variable (so 1), then you add 1 to global variable. Next time enemiround is created enemiround.variable will be 2. The reason its setting all crystals to same number right now is probably all enemirounds have the same number and I didn't mention you need to increment it.

  • Ah I missed out something there which may have confused you. You need a global variable that acts like a counter, then when you create enemiround object you set enemiround.variable to global variable (so 1), then you add 1 to global variable. Next time enemiround is created enemiround.variable will be 2. The reason its setting all crystals to same number right now is probably all enemirounds have the same number and I didn't mention you need to increment it.

    XD that was the missing part :) IT WORKS!!! thank you so much ;)

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