void Update() { if (positionShakeSpeed > 0) { transform.localPosition = position + Vector3.Scale(SmoothRandom.GetVector3(positionShakeSpeed), positionShakeRange); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.K)) { CameraShake(); } if (shake) { if (shakeTimer > shakeTime * Time.timeScale) { shakeTimer = 0; shake = false; Time.timeScale = 1; Camera.main.transform.position = new Vector3(originalPosition.x, originalPosition.y, originalPosition.z); } else { shakeTimer += Time.deltaTime; Camera.main.transform.position = originalPosition + Vector3.Scale(SmoothRandom.GetVector3(shakeSpeedCounter--), shakeRange); shakeSpeedCounter *= -1; shakeRange = new Vector3(shakeRange.x * -1, shakeRange.y * -1); } } }
public override void Execute(float currentTime) { var rotation = Quaternion.Euler(localRotation.eulerAngles + Vector3.Scale(SmoothRandom.GetVector3(shakeValue), new Vector3(4.0f, 4.0f, 4.0f))); actor.transform.localRotation = rotation; actor.transform.localPosition = localPosition + Vector3.Scale(SmoothRandom.GetVector3(shakeValue), new Vector3(0.1f, 0.1f, 0.1f)); }
public void DirectShake(float frequency, float amplitude) { transform.eulerAngles -= tMovement; tMovement = Vector3.Scale(SmoothRandom.GetVector3(frequency * Time.time), shakeRange) * amplitude; transform.eulerAngles += tMovement; }
public void ShakePosition() { /* * Update the localPosition by taking the original localPosition and adding a scaled Vector3. * The Vector3 is calculated by calling the SmoothRandom.GetVector3 function from the Perlin * script, which returns a pseudo-random Vector3 based on the given inputs. */ transform.localPosition = position + Vector3.Scale(SmoothRandom.GetVector3(positionShakeSpeed), positionShakeRange); }
void Update() { _transform.position = initPos + Vector3.Scale(SmoothRandom.GetVector3(speed), range); Vector3 randomRot = Vector3.Scale(SmoothRandom.GetVector3(speed), range); Quaternion newRot = new Quaternion(); newRot.x = initRot.x + randomRot.x; newRot.y = initRot.y + randomRot.y; newRot.z = initRot.z + randomRot.z; _transform.rotation = newRot; }
void Randomize() { if (!update) { return; } Vector3 v = SmoothRandom.GetVector3(randomSpeed); v.Scale(randomScale); steer.TargetPoint = v + offset; }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.K)) { CamShake(); } else { isShake = false; } if (isShake) { shake = SmoothRandom.GetVector3(shakeSpeed--); Camera.main.transform.position = originalCamPos + Vector3.Scale(new Vector3(shake.x, shake.y), shakeRange); shakeSpeed *= -1; shakeRange = new Vector3(shakeRange.x *= -1, shakeRange.y); } }
IEnumerator Shaker(float duration, float strength, float frequency) { float endTime = Time.time + duration; while (Time.time < endTime) { if (Random.Range(0f, 1f) > 0.5f) { shakeOffset.y = -(SmoothRandom.GetVector3(20).normalized *((Time.time / endTime) * strength)).y; } else { shakeOffset.y = (SmoothRandom.GetVector3(20).normalized *((Time.time / endTime) * strength)).y; } transform.position = cameraStartPos + (Vector3)shakeOffset; yield return(new WaitForSeconds(Random.Range(frequency - frequencyVariance, frequency + frequencyVariance))); } transform.position = cameraStartPos; yield return(null); }
void Update() { float fVertical = Input.GetAxis("Vertical"); float fHorizontal = Input.GetAxis("Horizontal"); if (fVertical != 0.0f || fHorizontal != 0.0f) { Vector3 tMove = ((m_tMoveForward * fVertical) + (transform.right * fHorizontal)) * m_fCameraSpeed; if (fVertical != 0.0f && fHorizontal != 0.0f) { tMove = tMove.normalized * m_fCameraSpeed; } tMove *= Time.deltaTime; m_tStartShakePos += tMove; } transform.position = Vector3.Lerp(transform.position, m_tStartShakePos, m_fCameraSpeed * Time.deltaTime); if (m_bShaking) { if ((Time.fixedTime - m_fShakeTimer) >= m_fShakeDuration) { m_fShakeTimer = 0.0f; m_bShaking = false; } else { transform.position = m_tStartShakePos + Vector3.Scale(SmoothRandom.GetVector3(m_fCurrentShakeSpeed--), m_tShakeRange); m_fCurrentShakeSpeed *= -1.0f; } } }
void Update() { Camera.main.transform.localPosition = SmoothRandom.GetVector3(speed) * movement; Camera.main.transform.LookAt(Camera.main.transform.parent.position + Camera.main.transform.parent.forward * 100 + SmoothRandom.GetVector3(speed) * rotation); }
public virtual void Update() { this.transform.rotation = Quaternion.LookRotation(new Vector3(1, 0.5f, 0.5f) + ((SmoothRandom.GetVector3(this.movementSpeed) - (Vector3.one * 0.3f)) * this.movementAmount)); if ((this.mouseOver == -1) && (Time.time > this.nextChangeTime)) { int curP = this.p; int curN = this.n; var displayNucleons = this.display.GetNucleons(); if (displayNucleons != null && displayNucleons.Length > 0) { int i = 0; while (i < displayNucleons.Length) { bool isProton = ((Random.value < (UnityScript.Lang.UnityBuiltins.parseFloat(this.p) / (this.p + this.n))) && (curP > 0)) || (curN == 0); displayNucleons[i].color = isProton ? this.protonColor : this.neutronColor; if (isProton) { curP--; } else { curN--; } i++; } this.display.SetNucleons(displayNucleons); } this.nextChangeTime = Time.time + this.changeInterval; } if ((this.lastP != this.p) || (this.lastN != this.n)) { this.Rebuild(); this.lastP = this.p; this.lastN = this.n; } }
void Update() { transform.position = position + Vector3.Scale(SmoothRandom.GetVector3(speed), range); }
public void ShakeRotation() { /* * This set rotationQuat equal to a pseudo-random rotation by taking the initial rotation(in Euler Angle format) * and adding a scaled Vector3 to it. The Vector3 is created by calling the SmoothRandom.GetVector3 function from * the Perlin script and multiplying the resultant Vector3 by the range to shake across. Then update the localRotation * to the new rotationQuat value. * */ rotationQuat = Quaternion.Euler(initialRotation.eulerAngles + Vector3.Scale(SmoothRandom.GetVector3(rotationShakeSpeed), rotationShakeRange)); transform.localRotation = rotationQuat; }