void Update() { if (Input.GetButtonDown("LeftBumper")) { if (canCollect) { bird.SetFetchState(); Debug.Log("send bird"); } else if (!canCollect && bird.target == perch) { bird.SetFollowState(); Debug.Log("bring bird"); if (transform.parent != null) { transform.parent = null; } } } if (Vector3.Distance(bird.transform.position, perch.position) < 0.1) { if (carried == false) { transform.parent = bird.transform; carried = true; } bird.SetFollowState(); } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("LeftBumper")) { if (canMove) { bird.SetFetchState(); Debug.Log("send bird"); } else { if (bird.target == perch) { bird.SetFollowState(); Debug.Log("bring bird"); } } } if (Vector3.Distance(bird.transform.position, perch.position) <= 0.1) { move = true; } else if (Vector3.Distance(bird.transform.position, perch.position) > 0.1) { move = false; } if (move) { Move(); } else if (!move) { ResetPosition(); } }