void Update() { m_timer = m_timer + Time.deltaTime; float t = m_timer / m_time; t = Mathf.Clamp01(t); float interp = Interpolation.BounceOut(t); transform.position = Vector3.LerpUnclamped(m_startPosition.position, m_endPosition.position, interp); }
public IEnumerator OnEnableStartAnimation() { m_collider2D.enabled = false; while (m_animationTimer < m_spawnAnimationTime) { m_animationTimer += Time.deltaTime; float t = m_animationTimer / m_spawnAnimationTime; t = Interpolation.BounceOut(t); transform.localScale = Vector3.Lerp(m_startingScale, Vector3.one, t); yield return(null); } m_collider2D.enabled = true; }
private void UpdateENTER() { m_timer = m_timer - Time.deltaTime; m_timer = Mathf.Max(m_timer, 0.0f); var animProgress = clamp(1.0f - (m_timer / m_enterTime), 0, 1); float interp = Interpolation.BounceOut(animProgress); transform.position = Vector3.LerpUnclamped(m_startPosition, m_position, interp); if (m_timer == 0.0f) { SetState(eState.ACTIVE); } }
private IEnumerator StartAnimationCoroutine() { m_collider2D.enabled = false; while (m_animationTimeElapsed < m_animationDurationTime) { m_animationTimeElapsed += Time.deltaTime; float t = m_animationTimeElapsed / m_animationDurationTime; t = Interpolation.BounceOut(t); transform.localScale = Vector3.LerpUnclamped(m_startingScale, Vector3.one, t); yield return(null); } transform.localScale = Vector3.one; m_collider2D.enabled = true; m_animationTimeElapsed = 0.0f; }
void Update() { if (m_delayStart <= 0.0f) { //add deltaTime to the current time m_currentTime += Time.deltaTime; if (m_currentTime < m_timeToReachPosition) { //based on which effect is selected this will lerp from the curretn position to the desired position switch (m_effect) { //Lerps using the BouceOut Interpolation case Effect.BOUNCE_OUT: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.BounceOut(m_currentTime / m_timeToReachPosition)); break; //Lerps using the ElasticOut Interpolation case Effect.ELASTIC_OUT: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.ElasticOut(m_currentTime / m_timeToReachPosition)); break; //Lerps using the Linear Interpolation case Effect.LINEAR: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.Linear(m_currentTime / m_timeToReachPosition)); break; //Lerps using the CircularOut Interpolation case Effect.CIRCULAR_OUT: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.CircularOut(m_currentTime / m_timeToReachPosition)); break; //Lerps using the CircularInOut Interpolation case Effect.CIRCULAR_IN_OUT: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.CircularInOut(m_currentTime / m_timeToReachPosition)); break; //Lerps using the CircularIn Interpolation case Effect.CIRCULAR_IN: transform.position = Vector3.LerpUnclamped(m_desiredPos + m_offset, m_desiredPos, Interpolation.SineIn(m_currentTime / m_timeToReachPosition)); break; } return; } //set the current position to the desired position transform.position = m_desiredPos; } else { //remove Deltatime from the m_delayStart m_delayStart -= Time.deltaTime; } }
public IEnumerator Shoot(Player player) { Transform oldParent = player.transform.parent; Quaternion oldRot = player.transform.localRotation; DamageType resistance = player.health.Resistance; player.transform.position = Barrel.transform.position; player.transform.SetParent(Barrel.transform, true); player.transform.up = Barrel.transform.forward; player.LookTowards(Barrel.transform.forward); // Immune to all... player.health.Resistance = DamageType.BASIC | DamageType.EXPLOSIVE | DamageType.FIRE | DamageType.ICE | DamageType.LIGHTNING | DamageType.EARTH | DamageType.TRUE; player.CanWalk = false; player.CanMove = false; player.CanRotate = false; player.CanAttack = false; player.HideWeapon(); while (aligning) { yield return(null); } // Charge Animation { Vector3 startPos = Barrel.transform.position; Vector3 endPos = BarrelChargePos.position; float startTime = Time.time; while (Time.time < startTime + ChargeTime) { float t = (Time.time - startTime) / ChargeTime; t = Interpolation.BounceOut(t); Vector3 pos = Vector3.Lerp(startPos, endPos, t); player.transform.position = pos; yield return(null); } } player.LookTowards(Barrel.transform.forward); player.CanRotate = true; // Launch Animation { AudioManager.Instance.PlaySoundWithParent("cannon", ESoundChannel.SFX, gameObject); player.ShowWeapon(); Vector3 startPos = BarrelChargePos.position; float startTime = Time.time; while (Time.time < startTime + LeapTime) { float t = (Time.time - startTime) / LeapTime; Vector3 pos = Utility.BezierCurve(startPos, Peak.position, Target.position, t); player.transform.position = pos; player.rotation += Vector3.right * PlayerRotateSpeed * Time.deltaTime; yield return(null); } player.transform.position = Target.position; } if (DestoryObjectOnImpact && DestroyableObject) { StartCoroutine(MakeDestroyableObjectFall()); } Explosion(player.transform.position); AudioManager.Instance.PlaySoundWithParent("thud", ESoundChannel.SFX, player.gameObject); player.CanWalk = true; player.CanMove = true; player.CanAttack = true; player.transform.SetParent(oldParent, true); player.transform.localRotation = oldRot; player.health.Resistance = resistance; }