Get the X and Y of a collision point

Discussion and feedback on Construct 2

Post » Fri Mar 25, 2016 10:39 pm

Hello, when a collision occurs between two graphics ... is there any way to get the X coordinate and Y coordinate of the collision point ?.
I do not think that's possible but I need to know.

Is there any way to find out the collision zone ?.

I have two graphics:
1 - sprite object
1 - tilemap

When the sprite collides with the tilemap, I would like to emphasize the point of the collision somehow.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Sat Mar 26, 2016 1:21 am

Something like this?
Image

Edit: sorry just saw you want the exact point. The one thing that pops into my mind are image points (but I don't know if this would work). So if possible I just would pin a few smaller invisible object to the obj_Player so I definitely know where it got hit.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Sat Mar 26, 2016 1:33 am

Search should give a few ways. In the case of a tilemap you first need to know the tiles the Sprite is overlapping. To help with searching, I've made a capx that does that.
After that the location the two objects are overlapping depends on the shapes of the objects. Keep in mind two objects can overlap at multiple places. One simple way could be to use the midpoint between the two objects, which works well if the objects are the same size and shape. There are also some more involved ways, but search should give more info about those.
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Sun Mar 27, 2016 9:46 pm

R0J0hound wrote:Search should give a few ways. In the case of a tilemap you first need to know the tiles the Sprite is overlapping. To help with searching, I've made a capx that does that.
After that the location the two objects are overlapping depends on the shapes of the objects. Keep in mind two objects can overlap at multiple places. One simple way could be to use the midpoint between the two objects, which works well if the objects are the same size and shape. There are also some more involved ways, but search should give more info about those.


Hi, thanks for the info, I'll see what I can do but I do not have much hope of getting it.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Mon Mar 28, 2016 3:57 am

It could be useful to know the shape of your sprite(s) and tilemap(s) to think of a way to work this.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Mon Mar 28, 2016 8:24 am

I'm not sure I understand, you mean the shape of the collision polygon box ?.

All forms I use are square and rectangular.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Mon Mar 28, 2016 11:59 pm

The idea isn't super difficult but i guess explaining it with text and implementing it is tricky.

1. we first need to know if the player is colliding with a tilemap. This is dead simple with one event.

2. we need to know what tiles the player is overlapping. This example here does that:
viewtopic.php?f=147&t=123332&p=877612&hilit=overlapping+tiles#p877612

3. So now we have a list of tiles overlapping the player. Here's a collection of ideas that search gives to get a rough collision point between two objects:
how-do-i-get-coordinates-of-span-class-posthilit-collision-span_p983039?#p983039

Guess one idea would be to get an average of all the tiles and use that.
Here's an idea to take the example from two and only use the part of the tile that's overlapping:
https://dl.dropboxusercontent.com/u/542 ... oint2.capx
works well if the sprite is only slightly overlapping the tiles
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Mon May 30, 2016 10:06 pm

R0J0hound wrote:The idea isn't super difficult but i guess explaining it with text and implementing it is tricky.

1. we first need to know if the player is colliding with a tilemap. This is dead simple with one event.

2. we need to know what tiles the player is overlapping. This example here does that:
viewtopic.php?f=147&t=123332&p=877612&hilit=overlapping+tiles#p877612

3. So now we have a list of tiles overlapping the player. Here's a collection of ideas that search gives to get a rough collision point between two objects:
how-do-i-get-coordinates-of-span-class-posthilit-collision-span_p983039?#p983039

Guess one idea would be to get an average of all the tiles and use that.
Here's an idea to take the example from two and only use the part of the tile that's overlapping:
https://dl.dropboxusercontent.com/u/542 ... oint2.capx
works well if the sprite is only slightly overlapping the tiles

@R0J0hound Can this example be modified to work with collision point data on tiles, rather than just the entire tile?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue May 31, 2016 2:13 am

@Zebbi
The collision polygon isn't accessible from just events. That said, you can manually put the collision point locations in an array or something and just reference that instead. Or you can use a tiny sprite to find the collision shape by moving over an area and checking for collision.
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Tue May 31, 2016 9:30 am

R0J0hound wrote:@Zebbi
The collision polygon isn't accessible from just events. That said, you can manually put the collision point locations in an array or something and just reference that instead. Or you can use a tiny sprite to find the collision shape by moving over an area and checking for collision.

What would the most efficient way of doing this be really? Looping a bunch of points around the sprite?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Cliffu, Litoghvgvgv and 10 guests