[FIXED] How do I find overlaping objects

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello everyone,

    I am currently struggling with the fact that I can't operate on 2 different instance of the same object, inside a unique event.Here am trying to find an overlaping instance "player" set with a unique ID, and then destroy it. But I also have this same object (which has ID=0) inside the overlaping sprite, and this one I can't destroy.

    "EtreAnime" is a sprite pinned to "player', it also has the same unique ID and is in the same container.

    Am kinda lost here guys, do you know what i am doing badly ? Tryed many things but "is overlapping" just doesnt detect my other player

    Thanks a lot,

    Cheers,

    Mael

  • Hm, to find a specific UID you use the event in the cog, for each. Select the object types to loop through, and you'll loop through each of that type. Then a sub event from that event, using the cog again, but this time choose compare two values. For the first value do sprite.UID then your comparison greater than, less than, and then your target value.. In that sub event destroy the sprite...

    Compare two values is very useful. You can use it for accessing dictionary keys with a specific value... Checking distance... all kinds of stuff.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • HI, thanks for the advice but I need to pick an object here. One that collide with my detection sprite (which is a circle around the player).

    If I "for each" all the player, it still doesn't find out which one is collinding my circle... Which is weird ! I also say to him not to pick the one with id=0 cause it's the player himeself (gamepad 0)

  • I'm not sure I can help. Really need to see what's going on... too bad you couldn't post images yet, but you need certain reps to do that..

    Maybe if you explained it in clearer English.

    You have a player instantiated, and another object of the same type, just copy and pasted? And you have a circle that comes up around your player, and you want to test which enemies are in the circle? Find one enemy that's inside the circle?

    Attach an instance variables to your enemies. A Boolean set to false, called isInsidePlayerSight. Then add an event, every tick. Then add another condition, click the type your testing to overlap, and choose is overlapping another object, or oncollision with another object.. Click the circle.. then in the event click the object, set boolean value, turn isInsidePlayerSight to true... Then make a new event foreach of enemy. On the same event add a new condition choose enemy object, then find "is boolean instance variable set".. in that event do what you need to do to each enemy inside that circle.

  • The only problem is if you're doing it against two players of the same type you'll have problems, because your player will always be inside the circle. This is why I would use separate sprites for player 1 and player 2, even if they look the same, you'll save yourself a lot of headache by separating their events and data..

  • If it is two players of the same type just attach another condition to the loop. A second for each loop that says foreach player if uid not = to the uid of the one you want to not destroy... Still, I can't see what you're doing.

    If you have two players that look the same, don't cut and paste, make two sprites, but for enemies it doesn't really matter. Should make your coding easier..

  • Hi Jeremy,

    Thanks a lot for your help ! You have well draw my problem.

    It made me search elsewhere and I found that the problem was caused by the fact that my detection circle around a player is in the same container that this one.

    So when I tell him to find "players" in collision, it doesn't want anything else than its instance.

    It's fixed !

    Thanks a lot !

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