public void GrabBacon(int f) { print ("bacon is grabbed"); currentState = rawState.holding; Grabbed = true; fid = f; }
// Update is called once per frame void Update() { //print (currentState); if (currentState == rawState.holding) { if(Input.touchCount > 0) { //print ("Input touch while holding = " + Input.touchCount); //Touch newTouch; foreach (Touch tch in Input.touches) { RaycastHit2D[] hitInfos = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(tch.position), Vector2.zero); foreach (RaycastHit2D hitInfo in hitInfos) { //if(tch.fingerId == fid) //{ //print ("finger id match"); //newTouch = tch; transform.position = new Vector3(hitInfo.point.x, hitInfo.point.y, transform.position.z); //transform.position.y = hitInfo.point.y; break; //} } } } else { //switch state to falling fallingTime = Time.time + 4; currentState = rawState.falling; } } if (currentState == rawState.falling) { if(Time.time > fallingTime) { //eventual this needs to change the state to dropped gameObject.SetActive(false); } } RBLeftSpot = GameObject.Find ("Cooker_Left"); RBRightSpot = GameObject.Find ("Cooker_Right"); SpriteRenderer left = RBLeftSpot.GetComponentInChildren<SpriteRenderer> (); SpriteRenderer right = RBRightSpot.GetComponentInChildren<SpriteRenderer> (); if (gameObject.GetComponent<Renderer>().bounds.Intersects(left.bounds)) { // Do some stuff print ("intersection test"); } if (gameObject.GetComponent<Renderer>().bounds.Intersects(right.bounds)) { // Do some stuff print ("intersection test right"); } }