Question by
240Werewolf · Dec 06, 2015 at 02:49 PM ·
teleporting
Can someone help me with this code? I'm trying to make my player enter/exit a building by colliding with a plane and this doesn't seem to work.
This is the code I used as a component in my player: using UnityEngine; using System.Collections;
public class EnterRoom : MonoBehaviour { public string tagName; public StringValue getMapName; private string sceneName; public Animator anim;
void OnTriggerEnter (Collider col)
{
if(col.gameObject.tag == tagName)
{
StartCoroutine("EnterOrExit");
}
}
IEnumerator EnterOrExit ()
{
sceneName = getMapName.text;
anim.SetBool("isFading", true);
yield return new WaitForSeconds(0.5f);
anim.SetBool("isFading", false);
Application.LoadLevel(sceneName);
}
}
This is the code I used as a component in the plane: using UnityEngine; using System.Collections;
public class StringValue : MonoBehaviour { public string text; }
I tagged the plane as a "Building", selected the Tag Name to "Building" under the EnterRoom component, and set the Get Map Name as Plane (String Value). I don't know what else to do.
Comment