[Suggestion] 'Point Overlaps Object' Condition

0 favourites
  • 10 posts
  • There doesn't seem to be a condition in Construct 2's Sprite object that tests if a point (x,y) lies within the sprite's collision polygon. I feel there are plenty of reasons why such a condition should exist natively in C2:

    1. It provides fundamental information about an object's collision polygon that can aid in writing advanced custom collision detection code. Consider objects that climb slopes along their bottom-center image point but retain the information needed to use their bounding polygon when testing for collisions near edges, where their extremities must be off the edge if they are to fall. Or perhaps consider a scenario where you want to test if one object is fully contained within another.
    2. It provides a neat, reusable method for fetching information of this nature. Without this condition in C2, I would have to use a single pixel sprite. If I were to use this sprite and position it to the point in question each time I were checking for overlap, I would have to repeat this series of events for every object in question. It would be difficult to see at a glance what point I'm comparing against because those values would be overshadowed by the logic of the algorithm that involves positioning the sprite, etc. Functions won't work because then I would have to pass a parameter that refers to the object whose collision polygon I'm testing against. Let's say I pass it's IID. I don't see a way to Pick an object with an IID and test for overlap with it. I could use Families and UIDs, but that still makes it far more complex than it needs to be.
    3. Something as intricate and precise as a collision polygon could be used in countless ways, but we are presently only given one limited usage of it: to check if two objects overlap. The power and flexibility of defining a collision polygon to sub-pixel precision seems wasteful when only one essential use is allowed. More open access to the collision polygon (by way of checking if a point lies within it) would significantly increase the programming possibilities available to the game developer with very little increase in software complexity.

    All in all, I think this would be a great addition to C2. I apologize if there are already simple approaches to finding whether a point overlaps an object, but I asked in the 'How Do I?' forum and no one seemed to know of any.

    Thanks for considering my request!

  • You're in luck - I already added point collision tests for r137.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! Great timing. I'm looking forward to the next release. Thanks Ashley!

  • Hi Ashley. Thanks for all the work you've done helping develop Construct. Is there any possibility we could see a feature implemented soon that lets you check the point at which the extremities of two objects collide? I am currently developing a game which requires me to return the x,y position of the place at which two physics objects touch/collide, both of which have complex bounding boxes made up of several collision points.

    I can envision countless useful ways such a feature could be implemented into people's games. For mine I need to know the point of collision so that my character, which is a ball, can be made to 'jump' off of curved surfaces at a 90degree angle to them, but without knowing the point of collision it is impossible for me to assign a physics impulse on the ball away from the point of collision.

    Be the answer 'yay' or 'nay' I would greatly appreciate hearing back from you on the matter. Thanks a bunch!


  • All too coincidental. I came to Scirra just now to search "check collision with point", and while I was typing that, it caught my eye that the most recent post in the General forum (seeing this from the main forum landing page) was in this thread.

    Ashley, you say that you've implemented it into r137, great! When is that due to be released? Wait, just checked the release page, and wow it looks like it's out. I'm gonna give it a shot!

  • I see in the changelog for r139 (specifically r137:

    display collision polygons in layout view;

    How is this enabled, or where do we set the option to see these in layout view? Is it possible for troubleshooting & debugging to actually see it in the rendered game as well? Obviously I wouldn't leave it on for release, but I'm experiencing some collision issues I'd like to troubleshoot, and seeing the collision mask at runtime would be beneficial. But at the very least, how do I enable it in the layout view?

  • wizaerd under view

    there is checkbox for collision polys


    don't think option to view during runtime tho sorry

  • Thanx Dr... I was just coming here to say I had found it.

  • wizaerd

    well glad to know you found it :)

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