0 Favourites

How do I test when two objects are perfectly overlapped?

  • basically I have objects that are letters at one position and I also have the same number of identical letters at another position. At a certain moment the first set move towards the positions of the identical set through custom movement.

    My issue is that I can't seem to make the first set stop moving as they perfectly overlap. I've tried comparing Y's of both and disabling the movement/setting speed to 0 when they are equal, but it does not work. It's like they never hit perfectly on the dot although it's clear they do overlap at one point.

    If I just set them to stop moving when they overlap, they stop moving but it's nowhere close to being perfectly overlapped. I could probably just do the positions manually but I know there has to be a simpler way.

  • They probably never overlap perfectly..

    y=200 is not the same as y=199.9999

    you could for example compare distance between the two and if it's very small set the movement stopped and set the position to the exact coordinate..

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • They probably never overlap perfectly..

    y=200 is not the same as y=199.9999

    you could for example compare distance between the two and if it's very small set the movement stopped and set the position to the exact coordinate..

    That's what I was left to assume, but I figured it could very well be me making some sort of error.

    I googled for a bit and found this tutorial that has a linked capx file https://c2tutorials.wordpress.com/2014/ ... er-object/

    I'm sure there's a name for the formula, but in the tut they basically check if a smaller sprite is completely inside of another bigger sprite. If it is then the animation changes, but if even a sliver is outside of the bigger sprite then the animation is not changed. I used the same formula for my issue and it worked!

    Anyways, thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Your C2 tests
566 243,742
thisisblogs's avatar
thisisblogs
Unread hot topic Locked topic
198 18,665
Tom's avatar
Tom Construct Team Founder
Unread hot topic
99 10,152
karshinkoff's avatar
karshinkoff