Overlapping question

0 favourites
  • 6 posts
  • Have a quick question about overlapping, that i hope someone can explain to me.

    So i have this event:

    X = 10

    Event:

    For 1 to X

    Spawn family1 at random(1000), random(1000)

    subevent:

    family1 is overlapping family1

    family1 destroy

    add 1 to X

                  

    However they are still ending up overlapping at some point.

    I read in the tutorial section about picking newly created instances, and i cant see why this shouldnt work, as the newly created family instances are within the scope. Anyone know what im doing wrong?

  • For those that cares :)

    I did some more testing of this, trying to figure it out. And based on the article - "Understand the picking of newly created/spawn instances since R101" I cant see why it shouldnt work as its pretty much an exact copy of that. But for some reason the newly created instances doesnt seem to work with the overlapping test, when its added as a subevent. As im setting lots of other values as part of these subevents which works fine.

    However if you move the overlapping test into its own event it works fine, and do some workaround, i think you can get it to work kinda the same way.

    The purpose of this is to make a part of a random map generator that add X amount of different graphic elements to a map, but at the same time makes sure that if these elements are not overlapping, they are destroyed and a new one is made.

  • When you create a new object then that object is picked. So in the subevent when you have 'family1 is overlapping family1', you only have the last created family1 object picked. You're checking for overlaps with just one sprite.

    In the past you'd put a 'pick all' condition in there but I was just trying it and putting 'pick all' after creating a sprite only picks the old sprites and doesn't include the newly created one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So if i understand you correct it just doesnt work in a subevent, due to that?

    I have no clue how the overlapping check is done, but thought that it was done by taking each instance, in this case only the newly created one and just go through each of the elements that its told to check for overlapping and see if its true or not.

    But if i understand you correct its done in some way where it picks 2 instances that are overlapping and then return true, and since it only picks one instance in my subevent it will always return false?

  • If you have 10 sprites and have an event:

    sprite is overlapping sprite
    

    that will check for overlaps between any of the 10.

    Say if half of them have 50% opacity so

    sprite opacity = 50
       sprite is overlapping sprite
    

    The first condition picks the 5 sprites with 50% opacity and then the subevent is only checking for overlaps within that group of 5.

    If you have:

    system create sprite
       sprite is overlapping sprite
    

    Create sprite picks only the newly created sprite so the subevent is checking for collisions within this group of 1.

  • Ahh ok i see.

    Thanks for clearing it up for me :)

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