Action Between Same Object Different InstanceValue

Get help using Construct 2

Post » Sun Mar 10, 2013 1:01 pm

Hello guys, I want to ask question regarding action that involve same object but different in instance value.

For example: I make one ball which have instance value "color". When the instance value is set to "red", the color become red. "Blue" become blue.

The question is I want the red ball to destroy the blue ball when colliding.

Is that possible?

Thanks!
B
21
S
5
G
1
Posts: 39
Reputation: 2,715

Post » Sun Mar 10, 2013 3:34 pm

Create 2 variables in the object.

Name one "colour" and set each instances value in the editor to "red" or "blue".

Name the other variable "overlapping_instance_ID".

add the event

object ball overlapping ball

set action

set "overlapping_instance_ID" to unique ball ID.

Create a subevent, and set the condition to

pick instance by unique id, and set the value to the variable "overlapping_instance_ID".

Now add another condition to the event, ball variable "colour" = "red", set action to destroy ball.

Alternatively you can use another object as a detector, do a for each loop on all balls named blue and set the detector to their position, then do another event and if detector overlapping ball and ball colour is red then destroy ball.
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Post » Mon Mar 11, 2013 4:55 pm

@Ethan Big thanks to you mate!

I applied your logic and here are the results:

First logic

Capx: http://dl.dropbox.com/u/70239636/test1.capx
Result: When red object overlap with another red object, both destroy. I don't know, maybe I got it wrong somewhere.

Second logic

Capx: http://dl.dropbox.com/u/70239636/test2.capx
Result: Work accordingly, although when I use For Each (Once), the collision object created every tick, I wonder if it is a bug. I want to test it with newer C2 version, but download keep failed.
B
21
S
5
G
1
Posts: 39
Reputation: 2,715


Return to How do I....?

Who is online

Users browsing this forum: Khamsou, nedzad and 14 guests