// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { //pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, this.transform.position.z); Ray rayo = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Debug.DrawRay(rayo.origin, rayo.direction * 10, Color.yellow); dir = new Vector3(-rayo.direction.x, -rayo.direction.y, rayo.direction.z); velocidad = -Input.acceleration.y * 10; if (Physics.Raycast(rayo, out hit)) { Municion bola = hit.collider.GetComponent <Municion>(); if (bola != null) { if (hit.rigidbody != null && is_triggered == true && bola.ifHit == false) { Debug.Log("Hit!" + velocidad); hit.transform.SendMessageUpwards("Golpeado"); hit.rigidbody.AddForceAtPosition(dir.normalized * (5.5f + velocidad), hit.point, ForceMode.Impulse); } } } } }
public void OnTriggerExit(Collider other) { Debug.Log("Se ha salido: " + other.ToString()); Municion bola = other.GetComponent <Municion>(); if (other.tag == "pelota") //&& bola.ifHit == false) { intentos--; bola.dest = true; if (intentos > 0) { lanzar.activate = true; } else { Time.timeScale = 0; manager.ShowFinished(); } } }