// Update is called once per frame private void Update() { if (disabled) { return; } #if UNITY_ANDROID bool fire = MyInputManager.TriggerValue('r') > 0.5f; #else bool fire = MyInputManager.Primary2DAxisClick('r'); #endif if (remote.grabbed && fire) { primary2DAxis = MyInputManager.Primary2DAxis(remote.currHandIndicator); //explode if (primary2DAxis.y > 0 && primary2DAxis.x <= 0) { if (!expanded) { expanded = true; foreach (var ote in _objectsToExpand) { ote.Transform.localPosition = ote.Destination; } audioSource.pitch = 1; audioSource.Play(); } else { expanded = false; foreach (var ote in _objectsToExpand) { ote.Transform.localPosition = ote.Origin; } audioSource.pitch = -1; audioSource.Play(); } StartCoroutine(WaitForMilliseconds(500)); } //Pause Rotation if (primary2DAxis.y > 0 && primary2DAxis.x > 0) { mercedesPodium.rotate = !mercedesPodium.rotate; rotationPaused = !rotationPaused; StartCoroutine(WaitForMilliseconds(500)); } //Rotate left if (primary2DAxis.y < 0 && primary2DAxis.x <= 0) { if (!rotationPaused) { mercedesPodium.rotate = false; } device.transform.Rotate(new Vector3(0f, -mercedesPodium.rotationSpeed, 0f) * Time.deltaTime); if (!rotationPaused) { mercedesPodium.rotate = true; } } //Rotate right if (primary2DAxis.y < 0 && primary2DAxis.x > 0) { if (!rotationPaused) { mercedesPodium.rotate = false; } device.transform.Rotate(new Vector3(0f, mercedesPodium.rotationSpeed, 0f) * Time.deltaTime); if (!rotationPaused) { mercedesPodium.rotate = true; } } } }
void Update() { prim2DAxis = MyInputManager.Primary2DAxis('r'); if (!grabbed && Vector3.Distance(transform.position, MyInputManager.rightHandController.position) < grabbingDistance) { outline.enabled = true; if (MyInputManager.TriggerValue('r') > 0.5f) { outline.enabled = false; grabbed = true; foreach (var mr in MyInputManager.rightHandController.GetComponentsInChildren <MeshRenderer>()) { mr.enabled = false; } enableDescriptionTextsFor(5); transform.parent = MyInputManager.rightHandController.parent; transform.rotation = MyInputManager.rightHandController.rotation; transform.position = MyInputManager.rightHandController.position; currHandIndicator = 'r'; } } else { outline.enabled = false; } if (grabbed) { if (prim2DAxis.x < 0.3 && prim2DAxis.y < 0.3 && prim2DAxis.x > -0.3 && prim2DAxis.y > -0.3 && MyInputManager.Primary2DAxisClick('r')) { transform.parent = oldParent; transform.rotation = oldRotation; transform.position = oldPosition; if (currHandIndicator == 'r') { foreach (var mr in MyInputManager.rightHandController.GetComponentsInChildren <MeshRenderer>()) { mr.enabled = true; } } grabbed = false; //outline.enabled = false; } } if (!enableDescriptionTexts) { if (MyInputManager.GripValue('r') > 0) { foreach (var meshRenderer in descriptionTexts.GetComponentsInChildren <MeshRenderer>()) { meshRenderer.enabled = true; } } else { foreach (var meshRenderer in descriptionTexts.GetComponentsInChildren <MeshRenderer>()) { meshRenderer.enabled = false; } } } }