Overlap at Offset *Range*?

0 favourites
  • 5 posts
  • If I have an object, say a square, can i determine via "Overlap at Offset" if i am within 10 pixels of that square with my player? I want to avoid creating an invisible 'tester' sprite around each square since there is literally 100 of these squares on the layout... Plus, doing it that way, wouldnt I be instantly doubling my collision checks?

    Thanks so much for anyone who knows the answer. :D This community is amazing, and I look forward to when I am able to help someone with an issue, too.

    Eternally grateful.

  • System > Compare two values: distance(player.x,player.y,square.x,square.y) is less than 10 + is overlapping etc....

    Just make sure the compare condition is above the overlapping one, or it won't do anything ;) Also check your collisions in the debugger to get a good idea what's going on. You should always do this when adding/removing something that you expect to have an effect on the result, as the results may surprise you for better or worse!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yep, that's what it's used for. Overlapping at offset X=10, Y=10 for a square perimeter of 10 pixels.

  • Wow, thank you both so much, i didn't even think of that -- i appreciate the insight!

    Using this i was also able to modify another major aspect of my game which brought my total collision checks down by half... Amazing! Thank you so so much.

    One thing I cant quite determine is whether or not it's using the collision map or the actual sprite dimensions? From what it looks like, it's using the sprite dimensions, correct? So if it's a circle & not a square, the distance from the sprite in the top corner will be calculated according to the square sprite container, and not the actual circle sprite... Is that correct? It seems so..

    Thanks again!

  • s overlapping another object

    Is overlapping at offset

    True if any instance is overlapping any instance of another object. The collision polygons are taken in to account if set, as well as the object's size and rotation. The 'offset' variant will test for an overlap at an offset from the first object. For example, testing for an overlap at an offset of (100, 0) will temporarily move the object to the right 100 pixels, test for the overlap, then move it back again.

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