- Home /
Question by
Bentoon · May 13, 2016 at 12:07 AM ·
collisionraycastingloadlevel
raycast with events
We are using the google cardboard reticle to trigger a new scene if the collider you rollover is pressed.... So we modify the google cardboard teleport script so when the function is called we modified so it doesn't put the box randomly but would load a new level
the message isn't even making it to the console:
public void TeleportRandomly() {
// Vector3 direction = Random.onUnitSphere;
// direction.y = Mathf.Clamp(direction.y, 0.5f, 1f);
// float distance = 2 * Random.value + 1.5f;
// transform.localPosition = direction * distance;
RaycastHit hit;
if (hit.collider.gameObject.tag == "balcony"){
Debug.Log("YOYO");
Application.LoadLevel("balcony");
}
}
Comment
Answer by lassade · May 13, 2016 at 12:29 AM
See you are just creating the RaycastHit object to hold the information of an ray cast but you are never doing a raycast.
RaycastHit hit;
if (Physics.Raycast(origin, direction, out hit)) {
// hit happend ! use the hit variable to get if about it
}