public void ScaleParticleSystem(float scale) { ParticleTools particle = gameObject.GetComponent <ParticleTools>(); if (particle == null) { particle = gameObject.AddComponent <ParticleTools>(); } particle.ScaleParticleSystem(ParticleScale); }
// Update is called once per frame void Update() { // Check if the collectable has been collected if (collectable.Collected && activateParticles) { activateParticles = false; // Play the particle system once glowyParticles.Play(); // Deactivate the objects collision box and boxCollider.enabled = false; meshRenderer.enabled = false; // Stop the emission of the sparkles ParticleTools.StopEmission(sparkleParticles); } }
private void Dash() { // Check if the in ocean state is active, if not return from this function if (State == BoatState.PLAYER_NOT_IN_BOAT) { return; } // Return from the function is there is no energy left if (!StaticValueHolder.DashMeterObject.DashBarIsEmpty) { // Use one of the dash meters energies StaticValueHolder.DashMeterObject.UseDash(); // Add the dash force to the boat rb.AddForce(transform.forward * dashImpulse, ForceMode.Impulse); if (!IsDashing) { zoomLerpTime = 0; } // Start the timer IsDashing = true; elapsedDashTime = dashTime; // Play sound dashNoise.Play(); // Trigger dash animation boatAnimator.SetTrigger("Dash"); // Start emitting particle from the camera ParticleTools.StartEmission(dashCameraParticles); } }
private void Update() { // Change the state to the player not in boat state if the player isn't in the boat if (PlayerStateMachine.Instance.state != PlayerStateMachine.PlayerState.BOAT) { State = BoatState.PLAYER_NOT_IN_BOAT; } // Change what happens depending on the state switch (State) { case BoatState.IN_OCEAN: break; case BoatState.IN_SHALLOW_WATER: break; case BoatState.PLAYER_NOT_IN_BOAT: UpdatePlayerNotInBoatState(); break; default: break; } // Dashing timer if (elapsedDashTime > 0) { // Add the dash force to the boat rb.AddForce(transform.forward * dashForce, ForceMode.Force); // Change the camera's FOV if (zoomLerpTime < 1) { zoomLerpTime += Time.deltaTime / cameraZoomOutTime; StaticValueHolder.BoatCamera.m_Lens.FieldOfView = Mathf.SmoothStep(StaticValueHolder.BoatCamera.m_Lens.FieldOfView, dashFOV, zoomLerpTime); lensDistortion.intensity.value = Mathf.SmoothStep(lensDistortion.intensity.value, -30, zoomLerpTime); } elapsedDashTime -= Time.deltaTime; if (elapsedDashTime <= 0) { IsDashing = false; elapsedDashTime = 0f; zoomLerpTime = 0f; // Stop emitting particle from the camera ParticleTools.StopEmission(dashCameraParticles); } } else if (zoomLerpTime < 1) { // Change the camera's FOV zoomLerpTime += Time.deltaTime / cameraZoomInTime; StaticValueHolder.BoatCamera.m_Lens.FieldOfView = Mathf.SmoothStep(StaticValueHolder.BoatCamera.m_Lens.FieldOfView, originalBoatCameraFOV, zoomLerpTime); lensDistortion.intensity.value = Mathf.SmoothStep(lensDistortion.intensity.value, 0, zoomLerpTime); } Speed = Vector3.Magnitude(rb.velocity); // Calculate the percentage of the total speed the boat is going PercentageSpeed = Speed / maxSpeedInOcean; // Set the volume of the water on boat sound waterOnBoatNoise.volume = PercentageSpeed; // Set the emission of the boat trail and bubble particles depending on the boat speed if (Speed > speedToActivateTrailParticles) { if (!boatTrailParticlesEmitting) { boatTrailParticlesEmitting = true; // Enable particle emission ParticleTools.StartEmission(boatSideTrailsLeft); ParticleTools.StartEmission(boatSideTrailsRight); ParticleTools.StartEmission(bowBubbles); } } else { if (boatTrailParticlesEmitting) { boatTrailParticlesEmitting = false; // Disable particle emission ParticleTools.StopEmission(boatSideTrailsLeft); ParticleTools.StopEmission(boatSideTrailsRight); ParticleTools.StopEmission(bowBubbles); } } }