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

0 favourites
  • 4 posts
From the Asset Store
Assets for creating mountains and ravines environments
  • 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!

  • 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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

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