// Update is called once per frame void FixedUpdate() { if (activatePoint.position.y < transform.position.y) { GameObject LeftWall; LeftWall = theOjectPool.GetWallObject(); transform.position = new Vector3(LeftWallPos, transform.position.y - 15f, 0f); LeftWall.transform.position = transform.position; //newWall.transform.rotation = transform.rotation; LeftWall.gameObject.layer = 8; LeftWall.tag = "wall"; LeftWall.SetActive(true); GameObject RightWall; RightWall = theOjectPool.GetWallObject(); transform.position = new Vector3(RightWallPos, transform.position.y, 0f); RightWall.transform.position = transform.position; RightWall.layer = 8; RightWall.tag = "wall"; RightWall.SetActive(true); if (ObstacleSpawn()) { GameObject obstacle = theOjectPool.GetObstacleObject(); transform.position = new Vector3(ObstaclePos, transform.position.y, 0f); obstacle.transform.position = transform.position; obstacle.transform.rotation = transform.rotation; obstacle.SetActive(true); } } }
// Update is called once per frame void FixedUpdate() { RaycastHit hit; Ray ray = new Ray(Camera.main.transform.position, (go_Player.transform.position - Camera.main.transform.position)); LeftWall.SetActive(true); RightWall.SetActive(true); BottomWall.SetActive(true); TopWall.SetActive(true); if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask, QueryTriggerInteraction.Collide)) { hit.transform.gameObject.SetActive(false); } }