Overlap at Offset *Range*?

Get help using Construct 2

Post » Sun Dec 01, 2013 8:21 am

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.
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Sun Dec 01, 2013 8:26 am

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!
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

Post » Sun Dec 01, 2013 8:30 am

Yep, that's what it's used for. Overlapping at offset X=10, Y=10 for a square perimeter of 10 pixels.
B
45
S
15
G
73
Posts: 2,008
Reputation: 43,398

Post » Sun Dec 01, 2013 7:54 pm

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!
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Sun Dec 01, 2013 8:13 pm

[quote]Is 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.[/quote]
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to How do I....?

Who is online

Users browsing this forum: part12studios and 7 guests