Overlaping at offset question

Get help using Construct 2

Post » Thu Sep 27, 2012 11:35 am

I have following situation:



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
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Thu Sep 27, 2012 12:19 pm

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.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Thu Sep 27, 2012 12:48 pm

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.
podpathos2012-09-27 15:04:09
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Thu Sep 27, 2012 7:16 pm

@podpathos
[quote]In Construct Classic this works as I think it should, but in C2 something is wrong.[/quote]
This:
[quote]it seems to detect overlap when it's simply against.[/quote]
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.
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Tue Oct 02, 2012 8:47 pm

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.

podpathos2012-10-03 10:36:01
B
12
S
2
G
2
Posts: 96
Reputation: 1,583


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests