Get the X and Y of a collision point

0 favourites
  • 13 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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.

  • Something like this?

    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.

  • 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.

  • 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.

  • It could be useful to know the shape of your sprite(s) and tilemap(s) to think of a way to work this.

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

    All forms I use are square and rectangular.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • 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?

  • 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.

  • 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?

  • 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.

    I think that's pretty good.

    Set yourself some image points in the sprite.

    Check if collision sprite player with tilemap.

    If have a collision, placed a small sprite in every image point and check if collision occurs tilemap at that point, then you get that image points have collision.

  • Probably using the collision polygon.

  • Probably using the collision polygon.

    Tried pinning 8 different detectors, but it ate resources on mobile, so I'll have to go with the basic option of creating a spark under the car and using my imagination

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