Targetting specific instances of an object

This forum is currently in read-only mode.
From the Asset Store
Aim carefully a shoot the ball at the target to earn scores!
  • Hi,

    I'm currently making a 2D platformer project (aided massively by the wonderful tutorial by Deadeye) and being very new to construct, I don't understand how to solve a problem in my program:

    In the game, you collect crystals (in the typically clich�d manner), and I have an event wherein collision between the player and Crystal causes crystal to become invisible, and the HUD count of crystals to increase by one.

    However, ALL instances of crystal disappear when this event is triggered.

    How do I make just the specific instance of crystal disappear/cease to exist, instead of all instances?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instances of objects are 'picked' automatically by the conditions you have in events, if that makes sense.

    If you had a condition saying:

    Private variable 'health' of enemy is equal to 100, then any actions would only run on enemies with health of 100.

    If you have an event which says:

    Hero collides with crystal

    Then the only crystal that should be picked is the one involved in the collision. Could you post your .cap file or a screenshot of the event so we can see how it's set up? It's quite possibly an error in the event.

  • Oh boy is there egg on my face.

    On further investigation, I've found that every time I've tested the program, I've been grabbing the first crystal, but on jumping over it, it turns out that the others are invisible BEFORE event.

    This is because I have put on them on a different layer.

    erm. Sorry, and thanks for your quick reply

  • I have a question regarding targeting instances..

    What if the instance you are choosing isn't part of the event.

    Say you have 5 balls, you want the second ball to do something everytime.

    So your event would be [Always], now how do you do it so that only the second instance of the ball object is affected.

    you use Ball in the Always event whereas the event didn't use any condition or event that could pick a specific instance..

  • What if the instance you are choosing isn't part of the event.

    Say you have 5 balls, you want the second ball to do something everytime.

    So your event would be [Always], now how do you do it so that only the second instance of the ball object is affected.

    you use Ball in the Always event whereas the event didn't use any condition or event that could pick a specific instance..

    You can't, simple as that. If you want only a specific instance of an object to do something, you have to define how to pick that instance in a condition.

    So for your five balls you could number them 1 through 5, then in your condition do "+ballSprite.Value('mynum') is equal to 2" to pick the second one. If your instances can't be picked by built-in criteria like "is overlapping" then you have to make your own way of picking.

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