using System.Collections;
public class EnterWardrobeScript : MonoBehaviour {
// define insidewardrobe
public bool insideWardrobe = false;
//define outsidewardrobe
public bool outsideWardrobe = true;
public Transform destination;
public Vector3 thePositionToMoveTo;
public Vector3 playerPositionInside;
public Vector3 playerPositionOutisde;
public GameObject Teleporter;
public KeyCode key;
public bool inTeleporter = false;
public GameObject objectToTeleport = null;
void OnTriggerEnter(Collider hitObject )
{
Debug.Log("triggers happened: "+hitObject.gameObject.tag);
if( hitObject.gameObject.tag == "Player" )
{
objectToTeleport = hitObject.gameObject;
inTeleporter = true;
}
}
// Use this for initialization
void Start () {
//playerPositionOutside = Vector3;
//playerPositionInside = Vector3(-0.003018092, 0.235682, -0.1295382);
}
// Update is called once per frame
void Update () {
//if (playerPositionOutisde = Vector3(0, 0, 0) && (Input.GetKeyDown("E")))
//playerPositionInside;
if( Input.GetKey(key) && inTeleporter )
{
inTeleporter = false;
if( objectToTeleport != null )
{
objectToTeleport.transform.position = destination.position;
}
Debug.Log("e is pressed");
}
}
}
This is the script used to enter and exit the wardrobe using empty gameobjects as teleporters.
There are the teleporters of in and out that this script is assigned to
and the teleporter destination that you assign to the script in the ui of unity.
No comments:
Post a Comment