How do I pick Colliding Instances?

Get help using Construct 2

Post » Sat Mar 14, 2015 5:59 pm

Hi,

maybe this has been asked before, but how can I get the instances (IID, UID or custom variable) of 2 colliding objects of the same type?

bulletscollision.jpg


Thank you very much!
You do not have the required permissions to view the files attached to this post.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Sat Mar 14, 2015 10:33 pm

If you look in the "Falling Blocks" file in the examples folder, they show how to use a function with 'Pick instance with UID'.
B
9
S
1
Posts: 10
Reputation: 390

Post » Sun Mar 15, 2015 1:13 am

> @xeed :

if two objects collide, thos two are already picked by this event. Now you have to decide, which one you want to destroy or do something with it.

Let's say, you want to pick the first appearing bullet, and keep the newer one. That is easy:
You can pick the top or bottom (z-index) one very easily by the expression "Pick top (or bottom) instance". Since z-index is influenced by order of appearance, that means the older (or newer) can be made disappear.

Let's say, you want to destroy the one with lower speed:
Pick the top instance of the two colliding, just as before, than set a local variable to it's speed. You need this, since bullets to bullets comparison confuses things obviously. (Bullets.Bullet.Speed < Bullets.Bullet.Speed would compare it with itself, so does not work like that.)
Now you can compare to that local variable easily, see pic below for more details. (Of course it can be also health, or whatever attribute you compare of the two.)
You do not have the required permissions to view the files attached to this post.
B
8
S
3
Posts: 197
Reputation: 1,207

Post » Sun Mar 15, 2015 5:22 am

@MultipleChoice

This helps a lot, many thanks!
B
15
S
3
G
5
Posts: 396
Reputation: 4,977


Return to How do I....?

Who is online

Users browsing this forum: FlyingRam, jkmalau, MadSpy, Manubis and 10 guests