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

Teleporting First person camera

Discussion in 'Scripting' started by Mcboss762, Mar 4, 2018.

  1. Mcboss762

    Mcboss762

    Joined:
    Jun 27, 2017
    Posts:
    1
    Hi, so I'm making a first person parkour style game and I want to make it so when you fall off you go back to the start. I don't have any code and I'm pretty much a beginner with scripting so help would be greatly appreciated!

    And also, how do I make it say on the screen somewhere "[R] to Respawn" in the corner...

    Thanks for the help! Your Screenie 2018-03-04 at 11.00.30 am.png
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I'd highly recommend that you start with some much simpler examples.. Try here: https://unity3d.com/learn
    Look at Unity essentials, scripting, and simple games from which you can learn.

    When you've got a little experience, try modifying some of the games/tutorials that you've worked on, to add your own creative touch and work up & out from there! :)
     
  3. mehdimoji

    mehdimoji

    Joined:
    Oct 18, 2017
    Posts:
    22
    You can create an empty gameobject, place in where you want to respawn the player. then, if player fall off you have two choice : Restart the scene ( Time and Score will be zero) Or just Set the player position to R position.
    How to know when player fall off?
    you can create a collider below the lowest place, if player enter that : Fall off. or if you want better :

    look at this photo.
    on Collider below all (for debug) and two or three Collider under 5,6 place. it's the easy way for you.
    Code (CSharp):
    1. void OnTriggerEnter(Collider col)
    2. {
    3.    if(col.tag == "Player")
    4.    {
    5.    //RespawnPlayer();
    6.    col.transform.position = R.position;
    7.    }
    8. }
    this is so comfortable code. you must extend it. (Change your player tag to Player if not)