// Update is called once per frame void Update() { for (var i = 0; i < Input.touchCount; ++i) { if (Input.GetTouch(i).phase == TouchPhase.Began) { // Construct a ray from the current touch coordinates Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position); // Create a particle if hit RaycastHit hit; print("Sending Raycast"); if (Physics.Raycast(ray, out hit)) { print("Hit"); if (hit.collider == null) { return; } GameObject collided = hit.collider.gameObject; if (collided.tag == "Note") { collisionDetector det = collided.GetComponent <collisionDetector>(); //do something det.PlaySound(); } } } } }
void Start() { gm = gameMaster.master; rb2d = gameObject.GetComponent <Rigidbody2D>(); anim = gameObject.GetComponentInChildren <Animator>(); groundCheckObj = gameObject.GetComponentInChildren <objGroundCheck>(); wallCheck = gameObject.GetComponentInChildren <collisionDetector>(); platformCheck = gameObject.GetComponentInChildren <checkPlatformExit>(); biteZone = gameObject.GetComponentInChildren <playerAttackZone>(); hitBox = gameObject.GetComponentInChildren <playerRepel>(); target = GameObject.FindGameObjectWithTag("Frog").transform; if (alwaysAwake) { awake = true; state = (int)CrocState.STATE_WALKING; } else { state = (int)CrocState.STATE_SLEEPING; } pauseTime = Random.Range(3, 10); }