private void OnTriggerEnter(Collider other) { Rigidbody rb = other.GetComponent <Rigidbody>(); if (rb == null) { // Debug.LogError("There is no rigid body on the object (" + other.name + ") that collided with the trigger"); return; } if (rb.mass < massThreshold) { return; } if (rb.velocity.magnitude < speedThreshold) { Debug.Log(rb.name + " Had a speed of " + rb.velocity.magnitude + " on hit."); return; } Debug.Log(rb.name + " Had a speed of " + rb.velocity.magnitude + " on hit."); Debug.Log("Ball hit the window!!"); Destroy(gameObject); Debug.Log("BROKE WINDOW!"); //trigger the player being sucked into the window thing... FollowPathFromNearest followPath = GameObject.FindObjectOfType <FollowPathFromNearest>(); followPath.setWindowSuction(true); }
private void OnTriggerExit(Collider other) { //Debug.Log("Something exited the window"); if (other.gameObject.layer.Equals(LayerMask.NameToLayer("Triggers"))) { //trigger then portal suction somehow. FollowPathFromNearest followPath = FindObjectOfType <FollowPathFromNearest>(); Debug.Log("Fridge is gone from window now"); followPath.setWindowSuction(true); } if (other.gameObject.layer.Equals(LayerMask.NameToLayer("Player"))) { if (loading == false) { loading = true; //player goes out the window GameManager.instance.levelCompleted(); //temp to see if it actually works... MainMenu.loadLevelAfterLastCompletedLevel(); } } }