Picking issue in overlapping instances

0 favourites
  • 10 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hi Team,

    Please see the below pic. When the green box overlap either of this red instances, I want to set the variable of both instances as 1 even the green is not overlapping other red. but now only one instance is changing the variable.

    Tried the below code.

    Please see the attached C3p

    drive.google.com/file/d/1Ern7pKkfI4tkLdsoarBDofYn5hThRQeh/view

  • Do you mean all red sprites or only red sprites that are touching the one that was touched by the green sprite?

  • Not all, like a chain, if the green overlap 1st red instance, and the 1st red overlap 2nd one I want to change the variable of only those two, both 1st and 2nd one evenif the player is not touching the 2nd one

  • lionz like this

    If green is overlap C or D,variable of both C&D should be 1 and A&B should be 0

    Hope you get me

  • It's always difficult picking with the same object however if you change it to 1 when touching the green it does mean it's different. A second variable might also be useful to differentiate it from the others to work out what's happening.

    One way is to use system pick nth instance 0 and 1 in the overlap of red and red. You might be able to compare 0th instance where variable changed and then pick 1th instance and change that variable.

    Another way that is to put red sprite in a family. Then when you change the red sprite that is touching green to 1. You can say if family where var=1 (the red sprite) is overlapping red, then change red. This successfully picks the other red sprite as the first one was picked as family.

    They are the two ways I know of to do this.

  • This else needs to be removed, it is sending the other block to always be 0 if the green block is not overlapping. Put that if the green block is not overlapping and the red block is = 1 it will be = 0. And that if a red block with value 1 is overlapping a block with value 0, that block will also have value 0. If the red block with value 0 is overlapping one with value 1, this block will also become 1, but here it would need the condition of the green block overlapping some red block. I believe this would work!

  • lionz Anonymousking

    Thanks for the reply.

    Didn't get both of you. Much appreciated if you can tell in detail.

    Anonymousking Removed the else condition still its not working.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here it is, my way didn't work so I ended up using a family for that.

  • Yeah, puting family works. Thanks

  • you can make 4 different texts , then do:

    green is overlapping at object

    green is overlapping at object
    text 1 set text "1"
    text 2 set text "1"
    text 3 set text "1"
    text 4 set text "1"
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)