void LateUpdate() { //update random reference if (dropRand == null) { dropRand = new Suimono.Core.Random(randSeed); } //update timing _deltaTime = Time.deltaTime; //Handle Transition Settings if (cancelTransition) { doTransition = false; cancelTransition = false; trans1Time = 1.1f; trans2Time = 1.1f; } if (doTransition) { doTransition = false; trans1Time = 0.0f; trans2Time = 0.0f; dropOff = new Vector2(dropRand.Next(0.0f, 1.0f), dropRand.Next(0.0f, 1.0f)); } trans1Time += (_deltaTime * 0.7f * wipeTime); trans2Time += (_deltaTime * 0.1f * dropsTime); }
void LateUpdate() { _deltaTime = Time.deltaTime; if (cancelTransition) { doTransition = false; cancelTransition = false; trans1Time = 1.1f; trans2Time = 1.1f; } if (doTransition) { doTransition = false; trans1Time = 0.0f; trans2Time = 0.0f; dropOff = new Vector2(dropRand.Next(0.0f, 1.0f), dropRand.Next(0.0f, 1.0f)); } trans1Time += (_deltaTime * 0.7f * wipeTime); trans2Time += (_deltaTime * 0.1f * dropsTime); }
void EmitSoundFX() { if (actionPass) { if (audioObj != null && moduleObject != null) { if (moduleObject.gameObject.activeInHierarchy) { if (rulepass) { moduleObject.AddSoundFX(audioObj, emitPos, new Vector3(0f, fxRand.Next(audioPit.x, audioPit.y), fxRand.Next(audioVol.x, audioVol.y))); } } } } }
void SetUpdate() { if (moduleObject != null) { //set Random if (buyRand == null) { buyRand = new Suimono.Core.Random(randSeed); } //check activations performHeight = true; if (physTarget != null && moduleObject.setCamera != null) { //check for range activation if (activationRange > 0f) { currRange = Vector3.Distance(moduleObject.setCamera.transform.position, physTarget.transform.position); if (currRange >= activationRange) { performHeight = false; } } if (activationRange <= 0f) { performHeight = true; } /* * //check for frustrum activation * camRange = 0.2f; * if (moduleObject != null && performHeight){ * if (moduleObject.setCameraComponent != null){ * currCamPos = moduleObject.setCameraComponent.WorldToViewportPoint(physTarget.transform.position); * if (currCamPos.x > (1f+camRange) || currCamPos.y > (1f+camRange)){ * performHeight = false; * } * if (currCamPos.x < (0f-camRange) || currCamPos.y < (0f-camRange)){ * performHeight = false; * } * } * } */ //check for enable activation if (!isEnabled) { performHeight = false; } } //perform height check if (performHeight) { // Get all height variables from Suimono Module object heightValues = moduleObject.SuimonoGetHeightAll(this.transform.position); isOver = heightValues[4]; waveHt = heightValues[8]; surfaceLevel = heightValues[0]; forceAngles = moduleObject.SuimonoConvertAngleToVector(heightValues[6]); forceSpeed = heightValues[7] * 0.1f; } //clamp variables forceHeightFactor = Mathf.Clamp01(forceHeightFactor); //Reset values isUnderwater = false; underwaterLevel = 0f; //calculate scaling testObjectHeight = (transform.position.y + buoyancyOffset - 0.5f); waveHeight = surfaceLevel; if (testObjectHeight < waveHeight) { isUnderwater = true; } underwaterLevel = waveHeight - testObjectHeight; //set buoyancy if (!keepAtSurface && rigidbodyComponent) { rigidbodyComponent.isKinematic = saveRigidbodyState; } if (!keepAtSurface && engageBuoyancy && isOver == 1f) { if (rigidbodyComponent && !rigidbodyComponent.isKinematic) { //reset rigidbody if turned off if (rigidbodyComponent.isKinematic) { rigidbodyComponent.isKinematic = saveRigidbodyState; } buoyancyFactor = 10.0f; if (isUnderwater) { if (this.transform.position.y + buoyancyOffset - 0.5f < waveHeight - surfaceRange) { // add vertical force to buoyancy while underwater forceMod = (buoyancyFactor * (buoyancy * rigidbodyComponent.mass) * (underwaterLevel) * splitFac * (isUnderwater ? 1f : 0f)); if (rigidbodyComponent.velocity.y < maxVerticalSpeed) { rigidbodyComponent.AddForceAtPosition(new Vector3(0f, 1f, 0f) * forceMod, transform.position); } modTime = 0f; } else { // slow down vertical velocity as it reaches water surface or wave zenith modTime = (this.transform.position.y + buoyancyOffset - 0.5f) / (waveHeight + buyRand.Next(0f, 0.25f) * (isUnderwater ? 1f : 0f)); if (rigidbodyComponent.velocity.y > 0f) { rigidbodyComponent.velocity = new Vector3( rigidbodyComponent.velocity.x, Mathf.SmoothStep(rigidbodyComponent.velocity.y, 0f, modTime), rigidbodyComponent.velocity.z); } } //Add Water Force / Direction to Buoyancy Object if (inheritForce) { if (this.transform.position.y + buoyancyOffset - 0.5f <= waveHeight) { waveFac = Mathf.Lerp(0f, forceHeightFactor, waveHt); if (forceHeightFactor == 0f) { waveFac = 1f; } rigidbodyComponent.AddForceAtPosition(new Vector3(forceAngles.x, 0f, forceAngles.y) * (buoyancyFactor * 2f) * forceSpeed * waveFac * splitFac * forceAmount, transform.position); } } } } } //Keep At Surface Option if (keepAtSurface && isOver == 1f) { saveKeepAtSurface = keepAtSurface; float testPos = (surfaceLevel - physTarget.position.y - buoyancyOffset); if (testPos >= -0.25f) { //remove rigidbody if (rigidbodyComponent != null) { //rigidbodyComponent.velocity = Vector3.zero; if (!rigidbodyComponent.isKinematic) { saveRigidbodyState = false; rigidbodyComponent.isKinematic = true; } } //set Y position physPosition = physTarget.position; physPosition.y = Mathf.Lerp(startYPosition, targetYPosition, lerpSurfacePosTime); physTarget.position = physPosition; } else { rigidbodyComponent.isKinematic = saveRigidbodyState; } //set timer for smooth blend lerpSurfacePosTime += Time.deltaTime * 4f; if (lerpSurfacePosTime > 1f || keepAtSurface != saveKeepAtSurface) { lerpSurfacePosTime = 0f; startYPosition = physTarget.position.y; targetYPosition = surfaceLevel - buoyancyOffset; //physTarget.position.y; } } } }