0 Favourites

How to get UID of two Overlapping objects ?

  • Hello here is my problem :

    I have 10 instances of the same sprite,

    I want that when one instance is overlapping another instance, one of the two instances stop its movement.

    But when I put the condition : when sprite is overlapping sprite -> stop the movement

    The problem is that the two instances stop their movement whereas I want only one of the 2 to stop its movement.

    So is there a way to get the UID of the two Overlapping objects and to do action separately with the two object ?

    Thanks for the answers

  • Use System|Pick Sprite Instance nth as a sub-event under the collision/overlap event.

    As a subevent after a collsion event there are only two instance to pick. The two instances that are overlap.

    It would look like this:

    Sprite| Is overlapping Sprite

    ...System|Pick Sprite Instance 0 -> Do something with the Sprite with the lower UID than the other.

    If you use 1 then you pick the Instance with the higher UID from both.

    To pick the UID from each one do this.

    Sprite| Is overlapping Sprite -> System| Set myUID1 to Sprite.UID

    ...System|Pick Sprite Instance 1 -> System| Set myUID2 to Sprite.UID

  • Really thanks Asmodean for the help, Here is a link to a capx that illustrates how to pick seperately two instances that are in collision done with your help :

    https://www.dropbox.com/s/rg7bpuodhq6e1 ... .capx?dl=0

    It's the same way to select instances with collision and overlapping, so I thought it was more interesting for me to put an example based on collision and physics for people to see how it works.

    in this capx, 2 sprites have physics gravity on it, when there is a collision, one sprite will jump and the other one will see its width increase, download the project with the link you will understand, if questions post it.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • That's a really nice example. Even after a year with Construct it amazed me how little code it take to make such a example.

    Nice work!

  • Yes it doesn't take a lot of code to do that, that's nice ! 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 Locked topic
198 18,668
Tom's avatar
Tom Construct Team Founder
Unread hot topic
167 14,516
DMT2005's avatar
DMT2005
Unread hot topic
98 7,599
norum82's avatar
norum82