Comparing between 2 instances of same object

Get help using Construct 2

Post » Fri Nov 02, 2012 5:10 am

How do I compare 2 instances of same object when I need an action triggered performed on one of the instances based on one of the instance variables when they collide.
B
7
Posts: 38
Reputation: 683

Post » Fri Nov 02, 2012 1:12 pm

If you know for sure what the value of the instance variable is on the object you want to affect.. you could just do:

+on object collision with object
+object.variable = [number]
     ->your actions

If however, you don't know what the value is.. but need to check for the one with a lower value for example.. (like health points) you could do:

+on object collision with object
+for each object ordered by object.health ascending
     -> stop loop
     -> your actions etc
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Mon Nov 05, 2012 3:39 am

So the for each after the on collision condition would only affect those involved in the collision?
B
7
Posts: 38
Reputation: 683

Post » Mon Nov 05, 2012 3:41 am

What I wanted to do is to propagate certain values on collision, something like a viral effect.
B
7
Posts: 38
Reputation: 683


Return to How do I....?

Who is online

Users browsing this forum: flemmig, semaso, Skebab, Virpoja, Yahoo [Bot] and 13 guests