Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Two CollisionEnter2D at once

Discussion in '2D' started by OutLaw3, Apr 22, 2016.

  1. OutLaw3

    OutLaw3

    Joined:
    Nov 27, 2015
    Posts:
    8
    well we all know how to make a CollisionEnter2D script attached to a switch wich allows the door to open for example , but is there a way to use two CollisionEnter2D , i mean you have to collide with 2 switches ( 1 by the player and the other by a box for example) to open the door ?
     
  2. Kazen

    Kazen

    Joined:
    Feb 17, 2015
    Posts:
    68
    Yes, you could have X number of switches needed to open a door. The door needs to hold a list of the switches that needs to be pressed to open the door, and then the door checks if the switches are "activated". If they are, open sesame! I don't know how you use the collisionenter2D, but I'm guessing that you activate the switch there. Just add the same type of function (collisionenter2D) with a box as with your player to activate the other switch.
     
  3. OutLaw3

    OutLaw3

    Joined:
    Nov 27, 2015
    Posts:
    8
    thanks man, i'll try it out