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

Get help using Construct 2

Post » Wed Aug 17, 2016 8:11 pm

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!
B
17
S
7
G
1
Posts: 157
Reputation: 1,878

Post » Wed Aug 17, 2016 8:18 pm

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.
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Post » Wed Aug 17, 2016 8:42 pm

plinkie wrote: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.
B
17
S
7
G
1
Posts: 157
Reputation: 1,878

Post » Wed Aug 17, 2016 8:57 pm

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.
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Post » Wed Aug 17, 2016 9:23 pm

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...
B
17
S
7
G
1
Posts: 157
Reputation: 1,878

Post » Wed Aug 17, 2016 9:40 pm

IID has no meaning within a Family.

Something to read:
https://www.scirra.com/tutorials/556/un ... o-families
B
33
S
18
G
27
Posts: 2,442
Reputation: 20,348

Post » Wed Aug 17, 2016 9:46 pm

@99Instances2Go, thanks, so how can I achieve my goal?
B
17
S
7
G
1
Posts: 157
Reputation: 1,878

Post » Wed Aug 17, 2016 9:52 pm

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.
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Post » Wed Aug 17, 2016 9:55 pm

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.
B
17
S
7
G
1
Posts: 157
Reputation: 1,878

Post » Wed Aug 17, 2016 10:06 pm

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.
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Next

Return to How do I....?

Who is online

Users browsing this forum: Kenthria and 13 guests