Search Unity

Making an oxygen system

Discussion in 'Getting Started' started by chimpanzeee, Nov 18, 2022.

  1. chimpanzeee

    chimpanzeee

    Joined:
    May 22, 2017
    Posts:
    7
    Hello,
    So I was playing some games and wondered how they did the oxygen system and how they decide if the player is underwater or not. Do they use triggers? I was thinking they would attach an object at the position of the mouth/nose of the player and would check if that object collides with the triggers or something like that. I might try to make it in Unity.. Any ideas, or clues of what the best system would be? Thanks.
     
  2. chimpanzeee

    chimpanzeee

    Joined:
    May 22, 2017
    Posts:
    7
    Anyone could send in the right track regarding an oxygen system with underwater/surface detection?
     
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    There are a handful of ways to do that. But you can use triggers/sensors, with some scripting for that. That is one way to do it.

    In some older games, the devs would sometimes put the trigger, on/over the objects entire body, like for example a human or a doggy. If the trigger is on/over the body of the human or doggy, and is completely underwater, or hits a certain point underwater, the oxygen system or meter starts.

    Another method, is to use a raycast to detect if the character is in the water, or not, but I haven't used raycast much, so I am not a big expert on it.:confused:
     
    Last edited: Dec 4, 2022
    DevDunk likes this.