Search Unity

How do I make it necessary for my player to stay on a platform before moving on to the next level?

Discussion in 'Scripting' started by unity_artbd2A4og35_A, Apr 20, 2019.

  1. unity_artbd2A4og35_A

    unity_artbd2A4og35_A

    Joined:
    Apr 20, 2019
    Posts:
    1
    Greetings!
    I have been working on a project that has a rocket as the main player which has to make it past obstacles to make it to the finish pad. http://nitro.duckdns.org:9999/projectBoost/ (Heres a link to it so you can see what I'm talking about.) Currently, the player can land however they want it will move onto the next level. However, I would like it necessary for the player to stay on the landing pad for about 3 seconds to be able to move on. How do I go about doing that?

    Thanks!
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Triggers sound like a good approach. Put a trigger collider around your landing area. You can then set up handling to be aware of when the player enters or leaves the trigger area (OnTriggerEnter/OnTriggerExit), and you can also handle an event for every frame the player remains within the trigger area (OnTriggerStay). You could, for example, start a timer when they enter, reset the timer when they leave, and in OnTriggerStay you could test whether the timer had accumulated enough seconds to proceed to the next level. That logic could also verify things like whether the rocket is in an upright position.