void Update() { if (mtm.doorTriggerActive) { dop.OpenDoor(); } }
void Update() { //tähän joku timeri if (doorTriggerActive) { dooropener = FindObjectOfType <DoorOpener>(); dooropener.OpenDoor(); } }
// Update is called once per frame void FixedUpdate() { if (yesUse) { if (hand == null) { print("ei tartuttu " + prevHandPos); pointInPivotCoords = transform.InverseTransformPoint(prevHandPos); } if (hand) { pointInPivotCoords = transform.InverseTransformPoint(hand.position); prevHandPos = hand.position; print("käsi käytössä " + prevHandPos); } var pointOnPlane = pointInPivotCoords; pointOnPlane.z = 0; var pointInWorld = transform.TransformPoint(pointOnPlane); var newRot = Quaternion.LookRotation(transform.forward, pointInWorld - transform.position); var newUp = newRot * Vector3.up; var newAngle = Vector3.Angle(newUp, neutral.up); if (newAngle > maxAngle) { return; } transform.rotation = newRot; angle = Vector3.Angle(transform.up, neutral.up); dir = neutral.InverseTransformDirection(transform.up); if (dir.x <= 0) { angle *= -1; } if (angle >= 30 && isActivated) { isActivated = false; print("jes"); switchOff.Invoke(); } else if (angle <= -30 && !isActivated) { isActivated = true; print("jos"); switchOn.Invoke(); } if (isActivated) { print("vipu aktivoitu ja ovi aukeaa"); dooropener.OpenDoor(); } } // did we just move to activation zone? // if ... // switchOn.Invoke(); // switchOff.Invoke(); }
IEnumerator DetectMonster() { while (Vector3.Distance(transform.position, monster.transform.position) >= checkDistance) { yield return(new WaitForSeconds(checkTime)); } // button pressed animator.SetBool("Pressed", true); doorToOpen.OpenDoor(); }
IEnumerator DetectKey() { while (Vector3.Distance(transform.position, key.transform.position) >= checkDistance) { yield return(new WaitForSeconds(checkTime)); } // door unlocked doorToOpen.OpenDoor(); activated = true; Destroy(key); }