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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making a new game, done everything but an invisible platform designed for respawning.

Discussion in 'Scripting' started by Ben Peppitt, Jun 21, 2016.

  1. Ben Peppitt

    Ben Peppitt

    Joined:
    Jun 21, 2016
    Posts:
    14
    I need someone's help to make a script that allows me to spawn back into the position that my player first started in. It's a thirdperson based game with the character "Ethan". I've tried another script and the collider isn't working or something... please help!

    Temporary script:
    public class Respawn : MonoBehaviour {

    public Vector3 SpawnPoint;

    void OnTriggerEnter (Collider col)
    {
    if (col.tag == "ThirdPersonController")
    {
    col.transform.position = SpawnPoint;
    }
    }
    }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    does something involved in the collision have a rigidbody?
    is the collider set to "trigger" in its inspector?

    comparisons of strings are case sensitive; double check the tag is exactly correct, spaces, case everything.

    also
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/ :)
     
  3. Ben Peppitt

    Ben Peppitt

    Joined:
    Jun 21, 2016
    Posts:
    14
    Can you make a script for me? I can add the .cs file name for you so it's easier for me. Please, thanks.

    Script: Respawn
    GameObject (collider): CollisionObject - It's a "floor plane"
    GameObject (Respawn point): SpawnPoint
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    wrong forum for that... and if the problem lies with something related to the questions I asked it's not a "script problem"... if you're having issues with understanding how things need to be setup I'd recommend having another look at the tutorials for the physics system in unity
    http://unity3d.com/learn/tutorials/topics/physics
     
    TaleOf4Gamers likes this.
  5. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Nope, as LeftyRighty suggested look into the Unity physics because it may just be that you missed something and the code is fine. It would be pointless programming a potential workaround for a simple issue if it can be fixed. Look into it first.
     
  6. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    One of the unspoken rules of the Scripting forum is to avoid "write my code for me" kind of questions. It's generally frowned upon and you're unlikely to find someone who will do it for you, particularly when the code you posted seems fine, and the problem is likely with your settings.

    Are you under a deadline or is this some sort of homework? Because it seems from this and from your earlier thread that you could benefit from spending time learning the basics of both C# and Unity. You won't be able to get much done if you're going to stop and ask for help at every minor stumbling block. And yours are pretty minor stumbling block.