About Overlap at offset on center of a tile

Get help using Construct 2

Post » Sun Dec 04, 2016 12:24 am

I have a sprite (spriteA, 40x40 px) which has a Bullet behavior , and when I activate the bullet, the sprite will be moving forward.
If the sprite A overlap a tile (same size, 40x40 px) called SpriteB , right on the center of the tile, it will activate something, or change the bullet direction (such as 270 degrees). The problem is, I dont know the overlap to offset coordinate. I've tried collision at imagepoint(0) but it doesnt work. Should I use Self.X or something ? Anyone could help ?

[img]E:/sprite.png[/img]
B
7
S
1
Posts: 16
Reputation: 409

Post » Sun Dec 04, 2016 6:13 pm

Relative.

'Is overlapping at offset' moves the object temporarily 'offset' amount of pixels and checks the overlap, and then moves it back.

With an offset x=20,y=-30, it moves the object (from its current position) 20 pixels on the x and -30 pixels on the y, checks for overlap (picks the objects) , and moves it back to current position.

So, important to understand, it is not checking for collision at that one point in space. It checks the whole collision polygon's of one object against another object.

If you want the offset to be an imagepoint.... then
offset on x = sprite.ImagePointX(n) - sprite.X
offset on y = sprite.ImagePointY(n) - sprite.Y

I you want to check for an overlap at a certain point in space, you have the system condition Pick overlapping point.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Dec 05, 2016 10:52 pm

Thanks :D . But to clarifying things, overlap means if a sprite touch another sprite (even by difference of 1 px) , it will be accounted as triggering something, right ? SO, in order to prevent this, I must make some sprites smaller by 1 or 2 px, right ? (in a maze-like level design)
B
7
S
1
Posts: 16
Reputation: 409

Post » Tue Dec 06, 2016 8:15 am

Indeed. Or scale. Or use a helper object. Or pick Pick overlapping point. Or use an animationframe with reduced polygones, but that you cant do when working with physics.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Dec 06, 2016 8:20 am

'Pick overlapping point' has a 'picking' side, but also a logic part. Can by very handy in a grid. This way (using the logic side).

Pick (object) overlapping point (imagepoint)
Else
At this point you know that there is no 'object' on that place.
So you could set some variable to represent a 'free' direction' to go.
Or, just move in that direction.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, evillair, NumberOne, rbailey83, Solomon and 9 guests