Collision Point

This forum is currently in read-only mode.
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Is there a built-in way to retrieve the X and Y coordinate, of a collision between to sprites?

  • No. When objects collide, there is usually a whole region of overlapping pixels, so you can't say a collision happened at only one pixel. Also, the collision algorithm is optimised and uses MMX to check 64 pixels at a time, so even if I tried to retrieve the first overlapping pixel, it would only be to within 64 pixels on the X axis - not particularly useful!

    What are you trying to achieve? Usually there is a suitable workaround, such as using trigonometry, or finding the half-way point between the objects, as a good estimate.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm trying to create a custom physics engine, and understood that I need to know the point at which a collision happens. I am new to 2d physics, and only at a grade 9 math level, so maybe I haven't yet realized that there is a way to find these coordinates using trig (I'm relatively new to that as well <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz" /> ).

    I just started understanding how programming works not to long ago, so sorry if that was a noobish question.

  • It's not a noobish question, but why not use the built in physics engine? <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /> Add a Physics movement to your objects.

    If you need the collision point to create an explosion or something, the halfway-point is a very rough approximation, ie. (Object1.X + Object2.X) / 2, (Object1.Y + Object2.Y) / 2. However this will not suffice for something as precise for your own physics engine - sorry, you're stuck there, that's what the Physics movement is for <img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" />

  • I would suggest another thing :

    Haveing the x and y of the "Only Point" collision mode customizable.

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