Search Unity

"You are leaving the misson"

Discussion in 'Editor & General Support' started by tomtomh5, Oct 30, 2014.

  1. tomtomh5

    tomtomh5

    Joined:
    Oct 7, 2014
    Posts:
    39
    Does anyone know how to make text appear and kill the player when the player leaves the mission area? The only way I can describe it is, for example, In GTA4 Online, when you travel so far out to sea, it counts down, and then kills you, so as you respawn back in the gaming area. I'd like to replicate this, but show a "Game Over" style screen.
    Any ideas?
     
  2. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Depends on how you wanna go about this? Simplest method would be to define the center of the mission area, and to periodically check in the player's distance from this - if the distance exceeds a set amount, start the timer 'til the player returns to being within the radius.
    Down side of that is, of course, that you can only have spherical mission areas.

    If you'd want to have something a little more detailed - perhaps forcing the player to stick to certain streets - then I'd go for triggers.
    Setting up trigger colliders & using either OnTriggerExit or OnTriggerEnter (depending on whether triggers define the area inside or outside the mission) to initiate or quit the countdown process.
     
  3. tomtomh5

    tomtomh5

    Joined:
    Oct 7, 2014
    Posts:
    39
    So, for example, use a big cube around the mission area and when the player leaves the cube, call in the OnTriggerExit function?
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    IIRC its better to define the out of bounds by a trigger zone, and when its entered just do your thing.
     
  5. tomtomh5

    tomtomh5

    Joined:
    Oct 7, 2014
    Posts:
    39
    Could you elaborate? Thanks.
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    Triggers in the places where he is out of bounds.
     
  7. tomtomh5

    tomtomh5

    Joined:
    Oct 7, 2014
    Posts:
    39
    Thank you. Do you know of any tutorials?
     
  8. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536