void SecondPortalActivated(TeleportSpot spot) { if (!_oneWayOnly) { TeleportPlayer(_firstPortal.transform.position); } }
private void Awake() { if (!spot1) { spot1 = this; foreach (Draggable dragg in GameObject.FindObjectsOfType <Draggable>()) { dragg.AddSpot(this); } return; } if (!spot2) { foreach (Draggable dragg in GameObject.FindObjectsOfType <Draggable>()) { dragg.AddSpot(this); } spot2 = this; } }
// Update is called once per frame void Update() { Vector3 rayDirection = transform.forward * rayLength; Debug.DrawRay(transform.position, rayDirection, Color.red, 0.1f); RaycastHit hit; if (Physics.Raycast(transform.position, rayDirection, out hit)) { // check if we hit a teleport spot TeleportSpot teleSpot = hit.collider.GetComponent <TeleportSpot>(); if (teleSpot != null) { if (isLeftController) { if (ViveInput.Instance.leftTriggerTouch) { Teleport(hit.collider.transform.position); } } else { if (ViveInput.Instance.rightTriggerTouch) { Teleport(hit.collider.transform.position); } } // TODO if (Input.GetMouseButtonDown(0)) { Teleport(hit.collider.transform.position); } teleSpot.HighlightOn(); } } }
void FirstPortalActivated(TeleportSpot spot) { TeleportPlayer(_secondPortal.transform.position); }