Using "Or" to activate events

Get help using Construct 2

Post » Mon Jan 02, 2012 7:48 pm

Hello everyone. I have a VERY simple question. I need an event that is activated if a "sprite X" is colliding with "sprite A" OR "sprite B" OR "sprite C". How can I do that?

Thank you for your time.
B
15
S
1
G
4
Posts: 39
Reputation: 2,606

Post » Mon Jan 02, 2012 8:08 pm

Create 3 different events for each collision check
You'll just have to copy the same action on the threeYann2012-01-02 20:09:31
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 02, 2012 8:09 pm

Right now there's not a nice way to do it. The best option would be using Families. You would check for collision with a family that would be composed of SprA , B , C etc. Hopefully this will be coming in the next version. Second option would be using of course OR event but C2 doesn't have it yet :( Third option is create a variable like 'Collided' so you do
sprite is overlapping/colliding with sprA -> Set Collided True
sprite is overlapping/colliding with sprB -> Set Collided True
sprite is overlapping/colliding with sprC -> Set Collided True

If Collided
Trigger Once (depends on wanted behavior) -> Do Event

Very ugly. There must be a nicer way but i formulate one right now :D
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Mon Jan 02, 2012 8:31 pm

Yann, thank you for your answer. However, I that's not exactly what I wanted. Actually, I tried to simplify my question and it came out wrong.
Here is an exemple of what I'm trying to do.

http://dl.dropbox.com/u/2739873/lasers.capx

I'm using for this exemple the laser system by R0J0hound.

All that I want is to stop the laser if it collides with "wall" OR "sprite2" (the F box).
With one event for every sprite, all that I got is that the laser don't stop at all, because it will only stop if the laser is colliding with all the objects at the same time.

sorry for english, not my first language. And thanks for your time.
B
15
S
1
G
4
Posts: 39
Reputation: 2,606

Post » Mon Jan 02, 2012 8:34 pm

Thank's for the info Kiyoshi. I'll wait for this to be implemented on the upcoming versions of construct 2, and if it don't, I'll use the "collided" variable idea.
B
15
S
1
G
4
Posts: 39
Reputation: 2,606

Post » Mon Jan 02, 2012 8:35 pm

Well for this specific case, put both inverted conditions into a single event.

This will mean
Repeat 30 times,
If laser is not overlaping a wall
   AND
If laser is not overlaping a sprite

THEN
Add 20 to laser's width.

Kyatric2012-01-02 20:37:03
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Jan 02, 2012 8:36 pm

Thank you, it worked just fine (:
B
15
S
1
G
4
Posts: 39
Reputation: 2,606


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], R0J0hound, randomly and 23 guests