void Update() { //Apply rotation based on Turning if (lr.getCurScreen() != lastScreen) { lastScreen = lr.getCurScreen(); if (!continuous) { velocity += (velocityAmount * lr.getLastDir()); desiredVelocity = 0; SoundManager.instance.PlaySound(blackGearSound); } if (continuous) { desiredVelocity = startVelocity * lr.getLastDir(); SoundManager.instance.StopSound(whiteGearSound); SoundManager.instance.PlaySoundDelayed(whiteGearSound, 0.3f); } } //Apply velocities velocity = Mathf.Lerp(velocity, desiredVelocity, Time.deltaTime * rotationFriction); //Rotate Gears based on velocity childGS.rotate(Time.deltaTime * (velocity * rotationMultiplier)); }
//CUSTOM FUNCTIONS=================================================================================================================== public void rotate(float angle) { desiredEuler.z += angle; //Reset desiredEuler if (desiredEuler.z > 360) { desiredEuler.z -= 360; } if (desiredEuler.z < -360) { desiredEuler.z += 360; } gearSpriteTransform.localRotation = Quaternion.Euler(desiredEuler); //Call rotate() on child Gear if (childGS != null) { childGS.rotate(-angle); } }