- Home /
Question by
The-Z-axis · Sep 10, 2019 at 05:32 PM ·
editorbuild-errortriggersrespawn
Triggers work in one built scene but not another
So I'm having a bit of an issue with some triggers in my game-
Up until now my respawn scripts have been working just fine in the editor, but when I made a new level and put the exact same scripts on new objects, it works fine in the editor but nothing happens in the build. The strangest part is that in the actual build the respawn scripts work fine in the first scene, but not the new one. I'm at my wit's end, I've been trying to crack this for days. Any insight would be unendingly appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Respawn : MonoBehaviour
{
// Start is called before the first frame update
public Transform teleportTarget;
public GameObject thePlayer;
void Awake()
{
thePlayer = GameObject.FindWithTag("Player");
}
void OnTriggerEnter(Collider other)
{
StartCoroutine ("waitOneSecond");
}
IEnumerator waitOneSecond()
{
GameObject PlayerCapsule = GameObject.FindWithTag("Player"); //
GameObject ThinnFroggo = GameObject.Find("2DFrog"); //Take all the player-related objects...
GameObject ThiccFroggo = GameObject.Find("FrogWalkCycle"); //
PlayerCapsule.GetComponent<PlayerMovement>().canMove = false; //
PlayerCapsule.GetComponent<PlayerMovement>().enabled = false; //
PlayerCapsule.GetComponent<ChangeYPosition>().enabled = false; //
ThinnFroggo.GetComponent<Movement2D>().enabled = false; //...And disable all their movement scripts
ThiccFroggo.GetComponent<Movement3D>().enabled = false; //
yield return new WaitForSeconds (1f); //Now wait 1 second...
thePlayer.transform.position = teleportTarget.transform.position; //And teleport to where we made the target!
ThinnFroggo.GetComponent<Movement2D>().enabled = true; //
ThiccFroggo.GetComponent<Movement3D>().enabled = true; //Now enable all the movement scripts again
PlayerCapsule.GetComponent<ChangeYPosition>().enabled = true; //
PlayerCapsule.GetComponent<PlayerMovement>().enabled = true; //
PlayerCapsule.GetComponent<PlayerMovement>().canMove = true; //
}
}
Comment
can i assume that you simply placed this script on a gameobject in the new scene?
Your answer
![](https://koobas.hobune.stream/wayback/20220612211954im_/https://answers.unity.com/themes/thub/images/avi.jpg)