Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float detectionRadius = 1.5f;
- private bool isInsideTrigger;
- public LayerMask triggerLayer;
- void Update()
- {
- Collider[] hits = Physics.OverlapSphere(transform.position, detectionRadius, triggerLayer);
- if (hits.Length > 0 && !isInsideTrigger)
- {
- isInsideTrigger = true;
- }
- if (!preLevel && hits.Length > 0 && isInsideTrigger && shortCollider.bounds.Intersects(hits[0].bounds))
- {
- Debug.Log(hits[0].gameObject.name);
- playerCanvas.transform.rotation = Quaternion.Euler(30f, -32.5f, 0f);
- GameObject interactiveObject = hits[0].gameObject;
- if (interactiveObject.CompareTag("Prepare Drink Table") && !objectAnalyserOccupaid)
- {
- Debug.Log("este se debe activar solo una vez");
- objectAnalyserOccupaid = true;
- int tempID = interactiveObject.transform.parent.GetComponent<MachinesID>().machineID;
- if (tempID == 1)
- {
- ActivePlayerSlider("prepare drink");
- }
- else
- {
- bartenderController.playerIsUsingSystem = true;
- ActivePlayerSlider("prepare drink 2");
- }
- }
- }
- if (hits.Length > 0 && isInsideTrigger && boolInteractions[0] && playerSlider.value < 1)
- {
- playerCanvas.transform.rotation = Quaternion.Euler(30f, -32.5f, 0f);
- int drinksInTable = serveDrinkTable1.drinksMadeCounter;
- if (drinksInTable < drinksTableMaxCapacity)
- {
- ActiveSlider("prepare drink");
- }
- }
- //si Saliste de algún trigger con el layer triggerLayer (no lee todos los colliders)
- if (hits.Length == 0 && isInsideTrigger)
- {
- isInsideTrigger = false;
- playerSlider.value = 0;
- playerCanvas.SetActive(false);
- for (int i = 0; i < boolInteractions.Length; i++)
- {
- boolInteractions[i] = false;
- }
- MachineController.Instance.DesactivateInteractions();
- if (bartenderController != null && bartenderController.playerIsUsingSystem)
- {
- bartenderController.playerIsUsingSystem = false;
- }
- objectAnalyserOccupaid = false;
- }
- }
- void ActiveSlider(string interactiveObject)
- {
- playerSlider.value += (Time.deltaTime * playerInteraction);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement