Overlaping at offset question

0 favourites
  • 5 posts
  • I have following situation:

    <img src="http://dl.dropbox.com/u/37009800/Construct%202/Need%20Help/overoff.png" border="0">

    Sprite on right side shouldn't overlap left or right because he's not inside obstacele, he's on it. Am I doing something wrong here?

    capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you're right, it seems to detect overlap when it's simply against. Maybe it's supposed to work that way? I'm not sure.

    Anyway here's a cap with a few changes:

    capx

    The main thing is I just made the collision polygon a slighly smaller square.

    I thought i saw some picking problems so i just instinctively added the 'for each' condition, it might not be necessary though.

    The detect variable is so it doesn't have to check for overlaps every single tick.. collision detection is relatively more cpu heavy than most actions..apparently

    and the set x to (int(self.x/16))*16 is just to add snapping.

  • Thanks for your help, but I made this example in order to understand

    overlaping at offset. I moved some sprites one pixel to show that it works only if sprite is not on obstacle but moved one pixel from it. In Construct Classic this works as I think it should, but in C2 something is wrong. I know that you can make it work but that is not the point, because: "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." (Manual)

    I would like to know how overlaping at offset works.

    Thanks again.

  • podpathos

    n Construct Classic this works as I think it should, but in C2 something is wrong.

    This:

    t seems to detect overlap when it's simply against.

    In C2 objects in contact count as overlapping, in CC they don't.

    So you are understanding how "overlapping at offset" works, it's just what counts as a overlap that is different.

  • Thanks R0J0hound for pointing out difference.

    But difference beatween what is overlaping at offset in CC and C2 is exactly that what leads to some problems in case you would like to make built-in platform behavior work "perfect" with smal sprites: to prevent sinking, penetrating sprites in obstacles for 1-3px.

    Why is that so:

    As I understand it, collision happens when sprite is on obstacle and it functions like triger. On the other hand 'overlaping at offset' in C2 funcions exactly the same as collision(=overlaping 1px), but not as triger, more like while: 'overlaping at offset 1' is basically equal to while it's coliding - if sprite rectancle is the same size of the collsion box.

    If solution to this is that you make collision rectangle smaller one px from sprite size, and then if sprite with platform behavior due to not working accuratly with small sprites sinks in ground, and you then set its position so that is visibly on obstacele (set SpriteY to Obstacle.Y-obstacle.Height/2-sprite.Height/2) it is not colliding whit it so you can't jump.

    If you make it collide so it can jump you can't use overlapinng left or right(overlaping at offset 1,0 or -1,0) becouse it is overlaping like colliding, standing on the line of obstacle...

    Yet again I think that what counts for overlaping in CC is better, because in C2 it's overlaping at offset of 1 is basicly same as collision detection.

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