void Update() { Color currentColor = hoverOffColor; Vector3 currentPos = orbitPaths[0].position; currentSpeed = Mathf.Lerp(currentSpeed, Vector3.Distance(currentPos, orbitorLastPos) * Time.deltaTime, Time.deltaTime * 2); if (speedFadeOut >= 0.0f && speedFadeOut <= 1.0f) { speedFadeOut += Time.deltaTime / 2.0f; } orbitorSpeedSound.volume = Mathf.InverseLerp(0.0002f, 0.0005f, currentSpeed * Mathf.Clamp01(speedFadeOut)); orbitorLastPos = currentPos; if (hoverTimer >= 0.0f && hoverTimer <= 1.0f) { hoverTimer += Time.deltaTime / (isHovered ? hoverDuration * 0.25f : -hoverDuration); float amount = Mathf.SmoothStep(0, 1, Mathf.Clamp01(hoverTimer)); currentColor = Color.Lerp(hoverOffColor, hoverOnColor, amount); } transform.rotation = Quaternion.LookRotation(transform.position - handle.position, Camera.main.transform.position - transform.position); transform.rotation *= Quaternion.AngleAxis(-90, Vector3.right); if (buildTimer < 1) { buildTimer += Time.deltaTime / buildDuration; currentColor.a = Mathf.Lerp(0, hoverOffColor.a, buildTimer); seedMat.SetColor("_Color", currentColor); if (buildTimer > 1) { glow.GetComponent <Renderer>().enabled = true; generator.SeedBuilt(); } } glow.localScale = Vector3.Lerp(smallGlow, largeGlow, Random.value); if (movingToFunnel && !movingDownPipe) { moveProgress += Time.deltaTime / moveDuration; transform.position = Vector3.Lerp(moveStartPos, moveEndPos, Ease.OutQuart(moveProgress)); transform.localScale = Vector3.Lerp(Vector3.one, smallScale, Ease.OutQuart(moveProgress)); if (moveProgress > 1) { generator.SeedInFunnel(this); glow.GetComponent <Renderer>().enabled = false; seedRenderer.enabled = false; } return; } if (noiseFadeTimer >= 0.0f && noiseFadeTimer <= 1.0f) { noiseFadeTimer += Time.deltaTime / (makingNoise ? noiseDuration : -noiseDuration * 2f); float amount = Mathf.SmoothStep(0, 1, Mathf.Clamp01(noiseFadeTimer)); seedSound.volume = Mathf.Lerp(0, 0.5f, amount); if (movingDownPipe && noiseFadeTimer < 0.0f) { Destroy(handle.gameObject); Destroy(gameObject); } } if (seedSound.volume < 0.1f && seedSound.isPlaying) { seedSound.Stop(); } if (seedSound.volume > 0.1f && !seedSound.isPlaying) { seedSound.Play(); } if (movingDownPipe) { transform.position = pipe.position; } else { Vector3 moveAmount = ((handle.position - (Vector3.up * 0.1f)) - transform.position) * Time.deltaTime * 10; transform.Translate(moveAmount, Space.World); seedHeight = Mathf.Lerp(seedHeight, Mathf.Clamp(Vector3.Distance(transform.position, handle.position) * 10, 0.9f, 1.1f), Time.deltaTime * 5); transform.localScale = new Vector3(1 / seedHeight, seedHeight, 1 / seedHeight); } }