"If Block on collision with Block" - which one is fired?

0 favourites
  • 14 posts
From the Asset Store
Place blocks on a board, join them together to form even bigger blocks!
  • Hello all

    How can I reference both block (or a specific one of them, for that matter) in the event "If Block on collision with Block"?

    outputting Block.UID always return the lower UID of the two... I need to get the newer one.

    Thanks!

  • With the on collision event, you can use Pick nth instance, instance 0 and instance 1 will be the two blocks colliding with each other and you can reference and use them in that way.

  • With the on collision event, you can use Pick nth instance, instance 0 and instance 1 will be the two blocks colliding with each other and you can reference and use them in that way.

    Thanks, but it seems nth instance refers to the entire Block collection inside the game, and not just the ones involved in the collision...

    Also, outputting Block.Count inside a blank sub-event inside the collision returns the global amount of Blocks.

  • It refers to the ones involved in the collision. On object collision > sub-event : Pick instance 0, Pick instance 1. Instance 0 is the first object to collide, instance 1 is the one collided with. So if you set up the following :

    On sprite colliding with sprite :

    ----Pick sprite instance 0 : Text 1 set Text sprite.UID

    ----Pick sprite instance 1 : Text 2 set Text sprite.UID

    Text 1 would show the UID of the sprite that collided and Text 2 would show the UID of the sprite that it collided with. This is how I do it when it is the same objects that are colliding.

  • You're right, plinkie, but I think I've found a bug...

    if Block is in a family - it always returns 1...

    Even if he's alone in that family - Block collision with Family will return PickedCount of 1, although the item that was collisioned with was Block as well...

  • IID has no meaning within a Family.

    Something to read:

    https://www.scirra.com/tutorials/556/un ... o-families

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 99Instances2Go, thanks, so how can I achieve my goal?

  • If 'Block' is a Family itself then PickedCount is 2, if 'Block' is within a family, PickedCount is still 2. Your PickedCount return action must be in the wrong place.

  • Here's a Capx I uploaded to demonstrate the problem:

    https://drive.google.com/file/d/0B5myBv ... sp=sharing

    Drag one sprite to another, you'll get PickedCount 1.

    change the on collision to Sprite instead of the family, and you'll get 2.

    I've noticed I put the alert in the same level as the event, but putting it under a blank sub-event didn't change the outcome.

  • I see what you mean, I was checking Family colliding with Family or Sprite colliding with Sprite. Is it essential that you use the logic Sprite colliding with any Family? I would just use the object name for picking as inheritance on families is strange.

  • plinkie, looks like a valid situation: an player collides with one of several types of players, and I want the 1st (or 2nd) player to be destroyed.

    Actually, for my game, I've change the gameplay a bit, so I don't need it as of now, but it's interesting how that can be achievable.

  • Make sure all the players are in one family and it's good to go

  • They are in the same family, but I wanted to check a single object type in that family to all others.

  • A bit confused with the example. If the family is gonna contain different sprites (objects), then 'is sprite over overlapping family' is a bit weird (in my eyes). If the family gonna contain instances of the same sprite, then use 'is sprite overlapping sprite'. Pick nth will work flawless, pickedcount will work flawless also.

    In the other case, if the family gonna contain different sprites, then make a second family. And use 'is family1 overlapping family2'. This works if both familys contain exactly the same objects. Only under those circumstances IID will make some sense. Pick nth will work flawless, pickedcount will work flawless also.

    I never uses 'is family1 overlapping family1'. You might try.

    The solution is in the link i suggested you to read, btw.

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