void Update() { if (powerController.GetState()) { transform.Rotate(new Vector3(rotationSpeed.x * Time.fixedDeltaTime, rotationSpeed.y * Time.fixedDeltaTime, rotationSpeed.z * Time.fixedDeltaTime)); } }
void FixedUpdate() { lastMotionDetection += Time.fixedDeltaTime; if (!pc.GetState()) { return; } Vector3 raycastStart = raycastAnchor; raycastStart.x -= 1; Debug.DrawRay(raycastStart, transform.forward * 7, Color.red); RaycastHit hit; if (Physics.Raycast(raycastStart, transform.forward, out hit, 7, layerMask)) { PlaySound(); lastMotionDetection = 0.0f; } raycastStart.x += 2; Debug.DrawRay(raycastStart, transform.forward * 7, Color.red); RaycastHit otherHit; if (Physics.Raycast(raycastStart, transform.forward, out otherHit, 7, layerMask)) { PlaySound(); lastMotionDetection = 0.0f; } if (lastMotionDetection < 5.0f) { if (leftDoor.position.z < leftZ + openingDistance) { leftDoor.Translate(new Vector3(openingSpeed * Time.fixedDeltaTime, 0, 0)); } if (rightDoor.position.z > rightZ - openingDistance) { rightDoor.Translate(new Vector3(openingSpeed * Time.fixedDeltaTime, 0, 0)); } } else { isSoundOnCooldown = false; if (leftDoor.position.z > leftZ) { leftDoor.Translate(new Vector3(-openingSpeed * Time.fixedDeltaTime, 0, 0)); } if (rightDoor.position.z < rightZ) { rightDoor.Translate(new Vector3(-openingSpeed * Time.fixedDeltaTime, 0, 0)); } } }