How do I find two sprites and only overlap eachother?

0 favourites
  • 5 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • I want to find sprites that overlap just one other sprite (my sprites are called XSquare in my code). I tried the "for each XSquare" approach pictured below, but it doesn't select anything. How can I find the set of all XSquare objects that only overlap one other XSquare object? (I can find all the ones that overlap, but not all the ones that just overlap one).

    Thanks for your time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi winkr7. It looks like you're using a global variable (overlap) which will keep a running total of all of your overlaps.

    I'd suggest you try using an instance variable instead so that the counter will give you an indication of how many overlaps each XSquare has. Then you can do a condition based on this being equal to exactly 1.

    Hope that helps.

  • Hundredfold I appreciate the suggestion, but it is an XSquare variable--I think the problem has to do with how to compare one XSquare with many XSquare--how does it know to limit the first to one single instance and then the next reference to XSquare is every other instance?

    But thanks for you comment.

  • Hopefully this will help. It uses 2 families and counts the number of overlaps between the sprites using For loops. Use the mouse to drag them around the screen and the number of overlaps for each is shown on a text object. The event sheet is quite straight forward - but depending on your application, it might be worth limiting the frequency of the check (I have it as every tick, but if you have a lot of sprites then the overhead will be quite large).

  • Thankyou very much colludium. I will look this over.



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