Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

changing bool with multiple triggers

Discussion in 'Getting Started' started by ThomasGaist, May 12, 2019.

  1. ThomasGaist

    ThomasGaist

    Joined:
    May 12, 2019
    Posts:
    11
    Hi everyone,
    I'm very new to game development and I've been working with unity for a couple of weeks now.

    I'm making a 2d platformer/fighter and I want to create a set of stairs for my character to walk on in the hub area.

    I want the player to be able to press "downarrow" if approaching the stairs from above in order to access them, and "uparrow" if he's approaching the stairs from the lower level.

    I've made this work by enabling and disabling the collider on the stairs (with a bool "onStairs") with a trigger. Unfortunately I've run into some collision issues that occur when player presses "uparrow" prematurely when approaching the steps from the wrong side, sending the player on an elevatorride through the staircase collider. I'm using a kinematic rigidbody, so platform effector2D is not an option as far as I can see.

    I figured I would solve the problem by placing several triggers:

    1. one at the bottom of the stairs that allows activating the stair collider with "UpArrow".
    2. one along the steps that allows the player to cancel the collider with "DownArrow".
    3. and one at the top that allows the player to access the stairs by pressing "DownArrow".

    So I basically want the three triggers to alter the same bool with different keypresses, but for some reason I can't make it work. Is it at all possible to go about solving my problem this way?

    I hope I've made my problem fairly clear, thank you very much in advance.