How do I get two objects UID's when they collide? (also repeated in open topic)

0 favourites
  • 5 posts
From the Asset Store
10 Orchestral Soundtracks / ~2 mins each / 11 audio clips in total
  • hello, I have been having issues with singling out UID's of two colliding objects which are both the same sprite (Bird). my intention is that the smaller bird gets destroyed and the bigger bird grows in size while many other birds do the same, but it keeps destroying other birds. how do I get the UID's of both birds when they collide? here is what I have so far. (also repeated in open topic)

  • Two methods:

    1.

    Bird on collision with Bird
    For each bird
    ... If loopindex=0 : set instance1 to Bird.UID
    ... If loopindex=1 : set instance2 to Bird.UID
    

    Create a family, then:

    Bird on collision with BirdFamily
    ... set instance1 to Bird.UID
    ... set instance2 to BirdFamily.UID
    

    And I suggest you move events 2 and 3 on your screenshot inside the "On collision" event, as sub-events. Then you won't need to use the variables. Also top-level events are running continuously on every tick, and you probably want them to only run once.

  • thank you, both methods are working to single out the two colliding Birds, but they don't always destroy the smaller bird. how could I alter the code to do so?

  • You can try something like this:

    Bird on collision with Bird
    System for each Bird ordered by Bird.width
    .. Bird destroy
    .. System Stop loop
    

    This should destroy the bird instance with the smallest width between the two.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ok thank you it worked!

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