/// <summary> /// Called when you take a cylinder our of the phonograph. Sets the alreadyInPhonograph bool to false and does some reset information /// </summary> private void TakeCylinderFromPhonograph(GameObject cylinderTaken) { VRTK.PhonographCylinder removedCylinderScript = cylinderTaken.GetComponent <VRTK.PhonographCylinder>(); //local variable to prevent loads of GetComponent<> calls. cylinderAlreadyInPhonograph = false; // moveNeedle = false; //UNCOMMENT THESE IF YOU DECIDE TO USE UPDATE // resetNeedle = true; //Reset phonograph needle HandleMoveNeedle(false); StopPlayingMusic(); //Reset cylinder properties after it has been removed removedCylinderScript.RotateCylinderControl(false); removedCylinderScript.UseGravityControl(true); removedCylinderScript.ActivateCylinderOutline(); }
/// <summary> /// Places a cylinder successfully in the phonograpgh. Handles the actions that need to be taken once the cylinder is placed in the phonograph /// </summary> /// <param name="cylinder"></param> private void PutCylinderInPhonograph(GameObject cylinder) { VRTK.PhonographCylinder scriptOnCylinder = cylinder.GetComponent <VRTK.PhonographCylinder>(); //Local ref to avoid long GetComponent calls. //There is no cylinder currently in the phonograph and we are putting this one in it cylinder.transform.position = transform.position; cylinder.transform.rotation = transform.rotation; audioSource.clip = scriptOnCylinder.ReturnAudioClip(); cylinderAlreadyInPhonograph = true; scriptOnCylinder.SetInsidePhonographTrigger(true); finishedTime = scriptOnCylinder.ReturnAudioClipLength(); scriptOnCylinder.RotateCylinderControl(true); scriptOnCylinder.UseGravityControl(false); // resetNeedle = false; //UNCOMMENT THESE IF YOU DECIDE TO USE UPDATE // moveNeedle = true; needleSpeed = distanceToTravel / finishedTime; //Calculate the speed at which to move the needle audioSource.PlayOneShot(audioSource.clip); HandleMoveNeedle(true); }