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 Start() { cam = gameObject.GetComponent <Camera>(); camtr = cam.transform; if (GameObject.Find("SUIMONO_Module") != null) { moduleObject = (Suimono.Core.SuimonoModule)FindObjectOfType(typeof(Suimono.Core.SuimonoModule)); moduleLibrary = (SuimonoModuleLib)FindObjectOfType(typeof(SuimonoModuleLib)); //moduleLibrary = GameObject.Find("SUIMONO_Module").GetComponent<SuimonoModuleLib>(); } if (moduleLibrary != null) { distortTex = moduleLibrary.texNormalC; //mask1Tex = moduleLibrary.texHeightC; mask2Tex = moduleLibrary.texDrops; } randSeed = System.Environment.TickCount; dropRand = new Suimono.Core.Random(randSeed); fogShader = Shader.Find("Hidden/SuimonoUnderwaterFog"); fogMaterial = new Material(fogShader); }
void Start() { // Object References if (GameObject.Find("SUIMONO_Module")) { moduleObject = GameObject.Find("SUIMONO_Module").GetComponent <Suimono.Core.SuimonoModule>() as SuimonoModule; if (moduleObject != null) { fxObject = moduleObject.fxObject; } } //populate system names if (fxObject != null) { sysNames = fxObject.sysNames; } //set random randSeed = System.Environment.TickCount; fxRand = new Suimono.Core.Random(randSeed); //run update loop at set FPS interval staggerOffset++; stagger = (staggerOffset + 0f) * 0.05f; staggerOffset = staggerOffset % staggerModulus; InvokeRepeating("SetUpdate", 0.1f + stagger, (1.0f / 30.0f)); }
void Start() { // Object References transf = this.transform; if (GameObject.Find("SUIMONO_Module")) { moduleObject = (Suimono.Core.SuimonoModule)FindObjectOfType(typeof(Suimono.Core.SuimonoModule)); if (moduleObject != null) { fxObject = moduleObject.suimonoModuleLibrary.fxObject; } } //populate system names if (fxObject != null) { sysNames = fxObject.sysNames; } //set random randSeed = System.Environment.TickCount; fxRand = new Suimono.Core.Random(randSeed); //run update loop at set FPS interval staggerOffset++; stagger = (staggerOffset + 0f) * 0.05f; staggerOffset = staggerOffset % staggerModulus; InvokeRepeating("SetUpdate", 0.1f + stagger, (1.0f / 30.0f)); }
void Start() { if (GameObject.Find("SUIMONO_Module") != null) { moduleObject = (Suimono.Core.SuimonoModule)FindObjectOfType(typeof(Suimono.Core.SuimonoModule)); } //set random randSeed = System.Environment.TickCount; buyRand = new Suimono.Core.Random(randSeed); //get number of buoyant objects if (applyToParent) { var buoyancyObjects = transform.parent.gameObject.GetComponentsInChildren <fx_buoyancy>(); if (buoyancyObjects != null) { splitFac = 1f / buoyancyObjects.Length; } } //set physics target if (applyToParent) { physTarget = this.transform.parent.transform; if (physTarget != null) { if (rigidbodyComponent == null) { rigidbodyComponent = physTarget.GetComponent <Rigidbody>(); } } } else { physTarget = this.transform; if (physTarget != null) { if (rigidbodyComponent == null) { rigidbodyComponent = GetComponent <Rigidbody>(); } } } }
void SetUpdate() { if (moduleObject != null) { //Cache Time for performance _deltaTime = Time.deltaTime; //check for action timing actionPass = false; if (actionIndex == 0 && actionCount < 1) { actionPass = true; } if (actionIndex == 2 && actionCount < actionNum) { actionPass = true; } if (actionIndex == 1) { actionPass = true; } if (actionCount > 0 && (actionIndex == 0 || actionIndex == 2)) { actionTimer += _deltaTime; if (actionTimer > actionReset && actionReset > 0f) { actionCount = 0; actionTimer = 0f; } } //set Random if (fxRand == null) { fxRand = new Suimono.Core.Random(randSeed); } //get objects while in editor mode #if UNITY_EDITOR if (!Application.isPlaying) { if (moduleObject == null) { if (GameObject.Find("SUIMONO_Module")) { moduleObject = GameObject.Find("SUIMONO_Module").GetComponent <Suimono.Core.SuimonoModule>() as Suimono.Core.SuimonoModule; fxObject = moduleObject.fxObject; } } } #endif if (Application.isPlaying) { //calculate camera distance if (moduleObject.setTrack != null) { currentCamDistance = Vector3.Distance(this.transform.position, moduleObject.setTrack.transform.position); if (currentCamDistance <= effectDistance) { //track position / speed if (savePos != this.transform.position) { currentSpeed = Vector3.Distance(savePos, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z)) / _deltaTime; } savePos = this.transform.position; // track timers and emit timerParticle += _deltaTime; timerAudio += _deltaTime; EmitFX(); if (timerAudio > audioSpeed) { timerAudio = 0f; EmitSoundFX(); } } } } } }
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; } } } }