Multiple SpawnPoints on on scene?

Hi all, I found this script and its supposed to work… But I’m a Noob at this so i need some serial handholding…:stuck_out_tongue: The SpawnPoint is not working and I’m wondering why?
Do I have to delete my Player from the scene he is entering? I read online about “don’t destroy on load” between scenes, but where should I write that? If that’s the case?

This Script Is attached to the Enterance Trigger Box:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelLoader : MonoBehaviour
{

    private bool playerInZone;

    private GUITexture triangleTexture;

    public string NextScene;
    public string SpawnPointName;


    // Use this for initialization
    void Start()
    {
        playerInZone = false;

        triangleTexture = GameObject.Find("Triangle").GetComponent<GUITexture>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Joystick1Button3) && playerInZone)//W was original
        {
            Application.LoadLevel(NextScene);
            GetComponent<SpawnAtSpawnPoint>().OnLevelWasLoaded();

        }
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")

        {
            playerInZone = true;

            triangleTexture.enabled = true;
        }
    }
    void OnTriggerExit2D(Collider2D other)
    {
        if (other.tag == "Player")

        {
            playerInZone = false;

            triangleTexture.enabled = false;
        }
    }
}

And this script is attacked to the “SpawnPoint Object”

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnAtSpawnPoint : MonoBehaviour
{

    GameObject spawnPoint;
    public string SpawnPointName;

    // Use this for initialization
    void Start()
    {
    }

    // Update is called once per frame

    public void OnLevelWasLoaded()
    {
        spawnPoint = GameObject.FindWithTag("SpawnPoint");
        if (spawnPoint.name == SpawnPointName)
        {
            transform.position = spawnPoint.transform.position;
        }
    }
}

I found these videos helpful, some things may be out of date but the parts about dontdestroyonload and removing duplicate players hold up

1 Like

Thanks, I will check them out!

It worked!
Only problem is that my Player remain his “main level” size when entering “cave”… He should scale up sinze the scene is more “zoomed in” when you go inside… But I will try to figure it out somehow… :=