private void Update() { Vector3 pos = obj.transform.localPosition; if (pos.z >= 3.5 && pos.z <= 5) { movement1.GetComponent <Rigidbody>().isKinematic = true; FindObjectOfType <Gamecontrol1>().Gameover(); } }
// Update is called once per frame void Update() { if (player == null) { player = FindObjectOfType <Movement1>(); } if (isFollowing) { transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10f); } if (player.GetComponent <PickuptwoD>().chickOnHead == true) { Chick = player.transform.GetChild(2).gameObject; PlayersHead = player.transform.GetChild(0).gameObject; watching4Throw = true; } if (watching4Throw) { if (Chick.transform.position.x != PlayersHead.transform.position.x) { Vector3 chickPos = new Vector3(Chick.transform.position.x, Chick.transform.position.y, -10f); isFollowing = false; transform.position = Vector3.MoveTowards(transform.position, chickPos, chickCamSpeed * Time.deltaTime); StartCoroutine(FollowChickTime()); } } }