Using "Or" to activate events

0 favourites
  • 7 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • 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.

  • Create 3 different events for each collision check

    You'll just have to copy the same action on the three

  • 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

  • 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.

    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.

  • 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.

  • 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.

    <img src="http://dl.dropbox.com/u/36472942/construct/forumhelp/2conditions.png" border="0" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you, it worked just fine (:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)