Getting crazy with overlapping

0 favourites
  • 6 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hi everyone, I can not figure out how to implement overlapping at offset function. See attached image please.

    I've trying to say: Press LEFT & if NOT overlapping wall (ostacolo) then move.

    But every time it cross the wall... :-( What i'm wrong??

  • Imagine 'Is overlapping at offset' like this: it takes the sprite's collision polygon, moves it from its current position by the x and y values specified, checks for overlaps and returns it to its original position. You can think of the x and y values for this function as if they were Sprite.X + entered x value, Sprite.Y + entered y value.

    ImagePointX() and ImagePointY() however return the position of an image point on your layout. For example, if your sprite moves to the right both it's own X and ImagePointX() get bigger so the offset at which you check for an overlap gets bigger.

    To fix this you need to enter a fixed value that doesn't change depending on your sprite's position, for example a simple number.

    Finally because this is in relation to the sprite's position if you want to check left or above you need to use a negative value.

  • Hi Hoodloc, still same issue...

  • It's hard to know what exactly you're trying to do. Could you post the rest of the logic for moving left?

    One thing to note is you're checking for the overlap in a trigger event (indicated by the little green arrow) which only happens once. So the overlap at offset will only be checked in the exact moment of the button press if you don't have another check somewhere else in your logic.

  • I'm trying to understand how to do, even using only this two lines i can't get it to work. Both are 32x32 sprites with collision 32x32 polygon.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm trying to understand how to do, even using only this two lines i can't get it to work. Both are 32x32 sprites with collision 32x32 polygon.

    The code you posted works but I guess it doesn't deliver the result you're expecting.

    Here's a quick demo I put together to demonstrate how overlap at offset works.

    dropbox.com/s/p5s3cpygccmu8eu/overlapAtOffset.c3p

    Left and right arrow to move the player left and right. Click on the + and - buttons to change the offset amount. The barely visible version of the player is a visualization of where the overlap is being checked.

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