[Resolved] Can I pass multiple numbers to Overlap at Offset

Get help using Construct 2

Post » Sat Jan 07, 2017 2:41 am

I'm looking to make a little "Press this button" message pop up when a player gets near an object. I'm using "Overlap at offset" for that, which seems to be working well, but I seem to need to create 2 events for every object (with a + and - X coord) for this to work properly. Is there a way to pass 2 numbers for the X coord in a single event?

For example, I would like the event to trigger when the player is at anywhere within 100 pixels left or right of the object (100 to -100)

Would also just like to add, I am using Overlap at Offset instead of just Overlap because I'd like to make some of the objects solid, so the player won't always be able to overlap with the object directly.

Thanks in advance!
Last edited by vampy3k on Sat Jan 07, 2017 4:26 am, edited 1 time in total.
Posts: 2
Reputation: 179

Post » Sat Jan 07, 2017 2:57 am

One way might be using a loop
System > For
start index 0,
end index 1
Object > Overlap at offset
Offset X: loopindex=0?-100:100

another way
If your collision polygons for the objects are just boxes you could maybe do:
System > Compare Two Values:
first value: object1.bboxright+100>object2.bboxleft&object1.bboxleft-100<object2.bboxright
comparison: =
second value: 1
Posts: 1,178
Reputation: 40,325

Post » Sat Jan 07, 2017 2:59 am

Keep in mind that overlapping at offset doesn't take into account over-shooting (i.e. if your player object has a collision poly less than 100 pixels wide, it's possible that it will think it's not overlapping when you're really close.
You may be better off testing for x coordinates if that is the case ( player.x > object.x - 100 OR player.x < object.x + 100 ).

Otherwise, you would have to use an OR block (which means you might need to nest it if there are other conditions in the block)
If overlap is what you're looking for, this is what you would use:
if overlapping at offset x - 100 OR overlapping at offset x + 100

Take a look at my itch.io games
Posts: 167
Reputation: 5,204

Post » Sat Jan 07, 2017 4:24 am

I've just run into the over-shooting issue while fiddling around with another collision, so yes, will definitely need to keep that in mind.

It sounds like my best bet then is to keep it as 2 checks, one for either side of the object. Thank you both so much for the super fast replies!
Posts: 2
Reputation: 179

Return to How do I....?

Who is online

Users browsing this forum: Metathronos and 13 guests