How do I remove value from a var when I stop overlapping obj

0 favourites
  • 4 posts
  • Hey guys.

    So this one is confusing me quite a bit. I want to add value to a var of an object when another instance of an object is overlapping it (one of many that could and would at the same time) then remove the same value when this instance of the object is no longer overlapping it.


    Object 1 has var which fills when ever an instance of Object 2 overlaps it, by the amount which is custom for every instance of Object 2. Take for example there are two Object 2s, one has a var with a value 20, the other 30. The Object 1 var value would become 50 when both Object 2 instances overlap it, but when one of them stops overlapping, the value would drop to 20 or 30, depending on which instance stops i making any sence?

    Any help on this would be hugely appreciated.



    Ok, so here is a quick capx illustrating the issue. It is a bit different than my original explanation, but basically it comes to the same thig.

    One event gives 20 when on of the two green squares overlaps the blue one, and the other gives 300. You have contorl over the one that gives 300. WHen you overlap the blue object, the text object will display the value that you add to. Now, what I need is a way to remove from the value the moment the controlable green square stops overlapping with the blue one.

    Any ideas?

  • Hey man,

    I see what you're up to.

    I modified your capx and corrected your initial event sheet.

    I also added another event sheet, called "Improved" which includes a function. Functions make your life way easier and this event sheet is also more compact than your initial one. I added several comments, I hope I can help you. :)

    (Switch between the Event Sheets by clicking your Layout and then choosing the Event Sheet on the left)

    If you have questions, don't hesitate to ask.


    Btw, you can add as many instances of Sprite2 and change their values to whatever you prefer, my improved version will still work. ;)

    (I changed the movement, you now control the Blue Sprite via Drag & Drop)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey man, thanks a million!

    This is really great and I got the idea - nice and simple. Great explanation, thanks again.

    Very helpful, exactly what I needed.

    Hope I can start being of help around this forum as well, still have a ways to go though .

    Thanks again.

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