Hermite() public static method

public static Hermite ( float start, float end, float value ) : float
start float
end float
value float
return float
Example #1
0
    private void updateMeleeAttack()
    {
        // If melee button is hit and not already in a melee attack then start attacking
        if (Input.GetButtonDown("Fire1") && Time.time > nextMelee)
        {
            nextMelee = Time.time + meleeTime;
        }

        // If we are still melee attacking then animate it
        if (nextMelee - Time.time >= 0)
        {
            float percent = Mathfx.Hermite(0, 1, (1 - (nextMelee - Time.time) / meleeTime));
            float angle   = mouseAngle + meleeArc * percent;
            angle -= meleeArc / 2f;

            Vector3 position = new Vector3(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad), 0);
            meleeObj.transform.position = transform.position + position * 0.6f;
            meleeObj.transform.rotation = Quaternion.Euler(0, 0, angle);

            //Debug.Log (angle);

            meleeObj.SetActive(true);
        }
        // Else hide the attack image
        else
        {
            meleeObj.SetActive(false);
        }
    }
    private IEnumerator SetValueCr(float value01, float time, bool useRealTime)
    {
        while (Animating)
        {
            yield return(null);
        }

        Animating = true;

        var from  = GetCurrentValue();
        var to    = value01;
        var delay = new Duration(time * Mathf.Abs(from - to), useRealTime);

        while (Animating && !delay.IsDone)
        {
            SetValue01(Mathfx.Hermite(from, to, delay.Progress01));
            yield return(null);
        }

        if (Animating)
        {
            SetValue01(to);
        }

        Animating = false;
    }
Example #3
0
    IEnumerator ScaleDown()
    {
        //Fade out the text
        float t     = 1;
        Color color = text.color;

        while (t > 0)
        {
            t         -= Time.deltaTime;
            color.a    = Mathfx.Hermite(0, 1, t);
            text.color = color;

            yield return(0);
        }


        //Scale down the bar
        t = 1;
        Vector3 scale = new Vector3(transform.localScale.x, 1, transform.localScale.z);

        transform.localScale = scale;
        while (t > 0)
        {
            t -= Time.deltaTime;

            scale.y = Mathfx.Hermite(0, 1, t);
            transform.localScale = scale;

            yield return(0);
        }
        gameObject.SetActive(false);
    }
Example #4
0
    SpawnPointEnemy GetAvailableSpawnPoint(SpawnPointEnemy[] spawnPoints)
    {
        Vector3 pos = Player.Instance.transform.position;

        float bestValue = 0;
        int   bestSpawn = -1;

        for (int i = 0; i < spawnPoints.Length; i++)
        {
            float value = 0;
            float dist  = Mathf.Min(14, (spawnPoints[i].Transform.position - pos).magnitude);
            value = Mathfx.Hermite(0, 7, dist / 7);

            // Debug.Log(i + " Spawnpoint " + spawnPoints[i].name + " dist " + dist + " Value " + value);
            if (value <= bestValue)
            {
                continue;
            }

            bestValue = value;
            bestSpawn = i;
        }

        //Debug.Log("Best spaqwn point is " + bestSpawn);

        if (bestSpawn == -1)
        {
            return(spawnPoints[Random.Range(0, spawnPoints.Length)]);
        }

        return(spawnPoints[bestSpawn]);
    }
        private IEnumerator TransitionRoutine(NavigationLocations location)
        {
            mIsTransitioning = true;

            // Change current NavigationButton's image and text from Selected color to Unselected color
            mButtonDictionary[mCurrentLocation].SetState(false, 10f);

            // Move background and "frame" from current location to target location
            mCurrentLocation = location;
            Vector3 from = mSelectionFrame.anchoredPosition;
            Vector3 to   = mButtonDictionary[mCurrentLocation].MyTransform.anchoredPosition;

            float timer = 0;
            float speed = 1f / mTransitionTime;

            while (timer < 1f)
            {
                timer += Time.deltaTime * speed;
                mSelectionFrame.anchoredPosition = Vector3.Lerp(from, to, Mathfx.Hermite(0, 1f, timer));
                yield return(null);
            }

            mSelectionFrame.anchoredPosition = to;

            // Change new NavigationButton's image and text from Unselected to Selected
            yield return(mButtonDictionary[mCurrentLocation].SetState(true, 10f));

            mIsTransitioning = false;
        }
Example #6
0
    SpwanPointEnemy GetAvailableSpawnPoint(SpwanPointEnemy[] spawnPoints)
    {
        Vector3 pos = Player.Instance.Agent.Position;

        float bestValue = 0;
        int   bestSpawn = -1;

        for (int i = 0; i < spawnPoints.Length; i++)
        {
            if (MyGameZone.IsEnemyInRange(spawnPoints[i].transform.position, 2))
            {
                continue;
            }
            float value = 0;
            float dist  = Mathf.Min(14, (spawnPoints[i].Transform.position - pos).magnitude);
            value = Mathfx.Hermite(0, 7, dist / 7);

            if (value <= bestValue)
            {
                continue;
            }

            bestValue = value;
            bestSpawn = i;
        }

        if (bestSpawn == -1)
        {
            return(spawnPoints[Random.Range(0, spawnPoints.Length)]);
        }
        return(spawnPoints[bestSpawn]);
    }
Example #7
0
    public override void OnUpdate()
    {
        if (_eventFlash.target == null)
        {
            IsFinished             = true;
            _eventFlash.IsFinished = true;
            return;
        }

        _currentRotationTime += Time.deltaTime * (360 * Agent.BlackBoard.rotationSmooth);
        if (_currentRotationTime >= _rotationTime)
        {
            _currentRotationTime = _rotationTime;
        }

        float      progress = _currentRotationTime / _rotationTime;
        Quaternion q        = Quaternion.Lerp(_startRotation, _finalRotation, Mathfx.Hermite(0, 1, progress));

        Agent.Transform.rotation = q;
        if (_rotationTime <= Time.timeSinceLevelLoad)
        {
            Agent.Transform.position = _eventFlash.finalPosition;
            Agent.Transform.LookAt(_eventFlash.target.Transform.position);
            IsFinished             = true;
            _eventFlash.IsFinished = true;
        }
    }
Example #8
0
    /// <summary>
    /// Return value based on curve from Mathfx class.
    /// </summary>
    /// <returns>The value.</returns>
    /// <param name="animationCurve">Animation curve.</param>
    /// <param name="start">Start.</param>
    /// <param name="end">End.</param>
    /// <param name="t">T.</param>
    public static float CurvedValue(AnimationCurveEnum animationCurve, float start, float end, float t)
    {
        switch (animationCurve)
        {
        case AnimationCurveEnum.Hermite:
            return(Mathfx.Hermite(start, end, t));

        case AnimationCurveEnum.Sinerp:
            return(Mathfx.Sinerp(start, end, t));

        case AnimationCurveEnum.Coserp:
            return(Mathfx.Coserp(start, end, t));

        case AnimationCurveEnum.Berp:
            return(Mathfx.Berp(start, end, t));

        case AnimationCurveEnum.Bounce:
            return(start + ((end - start) * Mathfx.Bounce(t)));

        case AnimationCurveEnum.Lerp:
            return(Mathfx.Lerp(start, end, t));

        case AnimationCurveEnum.Clerp:
            return(Mathfx.Clerp(start, end, t));

        default:
            return(0);
        }
    }
Example #9
0
    IEnumerator ScaleUp()
    {
        Color color = text.color;

        color.a    = 0;
        text.color = color;

        //Scaling the white bar
        transform.localPosition = new Vector3(piece.localPosition.x * 1 / transform.parent.localScale.x + offset.x, transform.localPosition.y + offset.y, piece.localPosition.z * 1 / transform.parent.localScale.z + offset.z);
        float   t     = 0;
        Vector3 scale = new Vector3(transform.localScale.x, 0, transform.localScale.z);

        transform.localScale = scale;
        while (t < 1)
        {
            t += Time.deltaTime;

            scale.y = Mathfx.Hermite(0, 1, t);
            transform.localScale = scale;

            yield return(0);
        }

        //Fading the text
        t = 0;

        while (t < 1)
        {
            t         += Time.deltaTime;
            color.a    = Mathfx.Hermite(0, 1, t);
            text.color = color;

            yield return(0);
        }
    }
Example #10
0
    public IEnumerator MoveSprite(Sprite s, float time, float delay, Vector2 leftDown)
    {
        yield return(new WaitForSeconds(delay));

        float   currentTime = 0;
        Vector3 start       = s.clientTransform.position;
        Vector3 end         = new Vector3((leftDown.x + _xOffset + (s.width / 2.0f)), (int)ZeroLocation * (-leftDown.y + _yOffset - (s.height / 2.0f)), 0);

        if (time == 0)
        {
            s.clientTransform.position = end;
            Transform(s);
            yield break;
        }

        float progress;

        while (currentTime < time)
        {
            currentTime += Time.deltaTime;
            if (currentTime > time)
            {
                currentTime = time;
            }

            progress = currentTime / time;
            s.clientTransform.position = Mathfx.Hermite(start, end, progress);
            Transform(s);
            yield return(new WaitForEndOfFrame());
        }
    }
Example #11
0
        private float AnimationCurveCompletionPerc(float origPercentage)
        {
            switch (AnimationCurve)
            {
            case AnimationCurves.Linear:
            {
                return(Mathfx.Lerp(0, 1, origPercentage));
            }

            case AnimationCurves.Elastic:
            {
                return(Mathfx.Berp(0, 1, origPercentage));
            }

            case AnimationCurves.Bounce:
            {
                return(Mathfx.Bounce(origPercentage));
            }

            case AnimationCurves.EaseInOut:
            default:
            {
                return(Mathfx.Hermite(0, 1, origPercentage));
            }
            }
        }
Example #12
0
    private void EnteringUpdate()
    {
        var t = getT(timeLastState, timeToEnter);

        if (t >= 1.0)
        {
            current_state = StepCompletePanelState.SHOWING;
            timeLastState = Time.time;
            if (panel_type == TutorialEventController.TutorialStates.PICK_UP_TOOL_GO_TO_PATIENT)
            {
                for (int i = 0; i < TutorialEventController.Instance.playerHasTool.Length; ++i)
                {
                    Tool.ToolType type      = TutorialEventController.Instance.playerHasTool[i];
                    bool          atPatient = TutorialEventController.Instance.doctorAtPatient[i];
                    if (atPatient)
                    {
                        AddPlayerCircle(i, type, true);
                    }
                    else if (type != Tool.ToolType.NONE)
                    {
                        AddPlayerCircle(i, type, false);
                    }
                }
            }
        }
        Vector3 newPos = Mathfx.Hermite(startPos, rect3posOrig, t);

        rectTrans.position = newPos;
    }
Example #13
0
    /* Refines each sample index in between the start slider sample index and the end slider sample index. Uses a Hermite curve to give
     * ease-in ease-out functionality. Slices the work into two halves, one from the start slider sample index to the last sample index,
     * and one from the last sample index to the end sample index. */
    private void ApplyRefinement()
    {
        float percent;
        int   startSliderSampleIndex = DMS.SFS_GetStartSliderSampleIndex(); // For caching
        int   endSliderSampleIndex   = DMS.SFS_GetEndSliderSampleIndex();   // For caching

        Vector3 diff = transform.position - samplePositions[lastSampleIndex];

        // From range [start slider sample index, last sample index]
        for (int i = startSliderSampleIndex; i <= lastSampleIndex; i++)
        {
            percent = (i - startSliderSampleIndex) / ((float)lastSampleIndex - startSliderSampleIndex);
            float   hermitePercent = Mathfx.Hermite(0.0f, 1.0f, percent);
            Vector3 offset         = diff * hermitePercent;
            alternativeSamplePositions[i] = samplePositions[i];
            samplePositions[i]            = samplePositions[i] + offset;
        }

        diff = transform.position - samplePositions[lastSampleIndex + 1];
        // From range (last sample index, end slider sample index], going backwards
        for (int i = endSliderSampleIndex; i >= lastSampleIndex + 1; i--)
        {
            percent = (endSliderSampleIndex - i) / (float)(endSliderSampleIndex - lastSampleIndex - 1);
            float   hermitePercent = Mathfx.Hermite(0.0f, 1.0f, percent);
            Vector3 offset         = diff * hermitePercent;
            alternativeSamplePositions[i] = samplePositions[i];
            samplePositions[i]            = samplePositions[i] + offset;
        }
    }
Example #14
0
    override public void Update()
    {
        //   if (Action.Target != null)
        //     UpdateFinalRotation();
        //Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), OwnerTransform.position + new Vector3(0, 1, 0) + tmp * 5 );

        CurrentRotationTime += Time.deltaTime * Action.RotationModifier;

        if (CurrentRotationTime >= RotationTime)
        {
            CurrentRotationTime = RotationTime;
        }

        float      progress = CurrentRotationTime / RotationTime;
        Quaternion q        = Quaternion.Lerp(StartRotation, FinalRotation, Mathfx.Hermite(0, 1, progress));

        // Debug.Log(q.ToString() + " " + StartRotation.ToString() + " " + FinalRotation.ToString() + " " + progress);

        Owner.Transform.rotation = q;

        if (EndOfStateTime <= Time.timeSinceLevelLoad)
        {
            Release();
        }
    }
Example #15
0
 // Update is called once per frame
 void Update()
 {
     if (current_state == PlayerCircleStates.APPEARING)
     {
         var t = (Time.time - startTime) / timeToAppear;
         if (t >= 1.0f)
         {
             current_state = PlayerCircleStates.SHOWING;
             startTime     = Time.time;
         }
         else
         {
             var newScale = Mathfx.Hermite(Vector3.zero, Vector3.one, t);
             rectTrans.localScale = newScale;
         }
     }
     else if (current_state == PlayerCircleStates.DISAPPEARING)
     {
         var t = (Time.time - startTime) / timeToAppear;
         if (t >= 1.0f)
         {
             current_state = PlayerCircleStates.NOTHING;
             startTime     = Time.time;
         }
         else
         {
             var newScale = Mathfx.Hermite(Vector3.one, Vector3.zero, t);
             rectTrans.localScale = newScale;
         }
     }
 }
Example #16
0
    IEnumerator LowerMusicVolume()
    {
        Debug.Log("Lower music volume");
        //target volume
        float loweredVolume = musicDefaultvolume / reducedMusicVolumeRatio;

        //Check if the music's volume is not already reduced
        if (musicAudio.volume == loweredVolume)
        {
            yield break;
        }

        //Reduce the volume over time
        float t = 0;

        while (t < 1)
        {
            t += Time.deltaTime * 2;
            musicAudio.volume = Mathfx.Hermite(musicDefaultvolume, loweredVolume, t);

            yield return(0);
        }

        StartCoroutine(CheckIfClipEnded());
    }
Example #17
0
    private void updateMeleeAttack()
    {
        // If the enemy should be attacking and is not already in a melee attack then start attacking
        if (attacking && Time.time > nextMelee)
        {
            nextMelee = Time.time + meleeTime;
        }

        // If we are still melee attacking then animate it
        if (nextMelee - Time.time >= 0)
        {
            float percent = Mathfx.Hermite(0, 1, (1 - (nextMelee - Time.time) / meleeTime));
            float angle   = meleeArc * percent;
            angle -= meleeArc / 2f;

            Vector2 position = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
            meleeObj.transform.localPosition = position * 0.5f;
            meleeObj.transform.localRotation = Quaternion.Euler(0, 0, angle);

            meleeObj.SetActive(true);
        }
        // Else hide the attack image
        else
        {
            meleeObj.SetActive(false);
        }
    }
Example #18
0
    override public void Update()
    {
        UpdateFinalRotation();
//		Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), FinalPosition + new Vector3(0, 1, 0));

        RotationProgress += Time.deltaTime * Owner.BlackBoard.RotationSmoothInMove;
        RotationProgress  = Mathf.Min(RotationProgress, 1);
        Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress);

        Owner.Transform.rotation = q;

        if (MoveOk && AnimEngine[Action.Data.AnimName].time > AnimEngine[Action.Data.AnimName].length * 0.1f)
        {
            // Smooth the speed based on the current target direction
            float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime;

            Owner.BlackBoard.Speed   = Mathfx.Hermite(Owner.BlackBoard.Speed, MaxSpeed, curSmooth);
            Owner.BlackBoard.MoveDir = Owner.Forward;

            float dist = Owner.BlackBoard.Speed * 2 * Time.deltaTime;
            MoveOk = Move(Owner.BlackBoard.MoveDir * dist);

            if (NoHitTimer < Time.timeSinceLevelLoad)
            {
                Owner.SoundPlayRoll();
                NoHitTimer = Time.timeSinceLevelLoad + 0.75f;
            }

            //  Åжϼ¼ÄÜÉ˺¦
            Vector3 dirToPlayer = Player.Instance.transform.position - Owner.Transform.position;

            if (dirToPlayer.magnitude < Owner.BlackBoard.WeaponRange)
            {
                ActionInjury injury = ActionFactory.Create(ActionFactory.E_Type.E_INJURY) as ActionInjury;
                injury.Impuls = (dirToPlayer).normalized;

                Player.Instance.GetComponent <AnimComponent>().HandleAction(injury);
                Player.Instance.Owner.BlackBoard.Health -= 10;
                Player.Instance.comboHitNum              = 0;
            }
        }

        if (Effect == null && Time.timeSinceLevelLoad > TimeToStartEffect && Time.timeSinceLevelLoad < TimeToEndEffect)
        {
            Effect = CombatEffectsManager.Instance.PlayWhirlEffect(Transform);
        }
        else if (Effect != null && Time.timeSinceLevelLoad > TimeToEndEffect)
        {
            CombatEffectsManager.Instance.ReturnWhirlEffect(Effect);
            Effect = null;
        }


        if (TimeToEndState < Time.timeSinceLevelLoad)
        {
            Owner.WorldState.SetWSProperty(E_PropKey.E_IDLING, true);
            Release();
        }
    }
Example #19
0
 public static Vector3 Hermite(Vector3 start, Vector3 end, float value)
 {
     return(new Vector3(
                Mathfx.Hermite(start.x, end.x, value),
                Mathfx.Hermite(start.y, end.y, value),
                Mathfx.Hermite(start.z, end.z, value)
                ));
 }
Example #20
0
        //void FixedUpdate() {
        //playerPhysBounds.transform.rotation = Quaternion.Slerp(playerPhysBounds.transform.rotation, targetRotation, Time.deltaTime * 3f);

        //Vector3 oldPos = playerPhysBounds.transform.localPosition;
        //transform.position = new Vector3(transform.position.x, playerPhysBounds.transform.position.y, transform.position.z);
        //playerPhysBounds.transform.localPosition = oldPos;

        //eyeParent.transform.position = playerPhysBounds.transform.position;
        //eyeParent.transform.position = playerPhysBounds.transform.TransformPoint(-headCam.transform.localPosition);
        //eyeParent.transform.rotation = playerPhysBounds.transform.rotation;


        //}

        void moveByDelta(Vector3 start, Vector3 delta, float moveTime)
        {
            float   distDelta = Mathfx.Hermite(0, 1, totalTime / moveTime) - distanceMoved;
            Vector3 deltaPos  = Quaternion.AngleAxis(headset.gameObject.transform.localEulerAngles.y, Vector3.up) * (delta * distDelta);

            transform.position += transform.rotation * deltaPos;
            totalTime          += Time.deltaTime;
            distanceMoved      += distDelta;
        }
Example #21
0
    // ==================================================================================================
    // === Main update functions ========================================================================
    void HealhBarUpdate()
    {
        if (!m_Initialised)
        {
            InitHealthBar();
        }

        if (!m_Visible)
        {
            ShowHealthBar();
        }

        //ppokud jsme srazili zdravi na nulu, ukonci corutinu, skryj bar
        if (currentHP <= 0)
        {
            //Debug.Log("Boss dead");
            HideHealthBar();
            CancelInvoke();
            return;
        }

        //pokud doslo ke zmene zdravi aganta, spusti novou animaci
        float agentHP = boss.HealthPercent;

        if (animTargetHP > agentHP)
        {
            animTargetHP = agentHP;

            float runningAnimProgressTime = 0;
            if (curAnimTime > 0)
            {
                runningAnimProgressTime = animTimeLength - curAnimTime;                 //kolik casu jsme uz odecetli
            }
            animTimeLength = (animStartHP - animTargetHP) / animSpeed;
            curAnimTime    = animTimeLength - runningAnimProgressTime;

            //srovnej s actualni interpolaci
            while (currentHP < Mathfx.Hermite(animStartHP, animTargetHP, Mathf.Clamp(1.0f - (curAnimTime / animTimeLength), 0, 1)))
            {
                curAnimTime -= 0.05f;
                //Debug.Log("Adjusting health anim time: currentHP " + currentHP + " newHP " + Hermite(animStartHP, animTargetHP, Mathf.Clamp(1.0f - (curAnimTime/animTimeLength), 0, 1)) );
            }

            //Debug.Log( "curAnimTime: " +  curAnimTime + " animStartHP: " + animStartHP + " animTargetHP: " + animTargetHP + " runningAnimProgressTime: " +    runningAnimProgressTime + " animTimeLength: " + animTimeLength);

            //spusti animaci zasahu
            if (hitAnimClip)
            {
                m_ProgressBar.PlayAnimClip(hitAnimClip);
            }
            //PlayHitAnim();
        }
    }
Example #22
0
    public IEnumerator Show()
    {
        float t = 0;

        while (t < 1)
        {
            t += Time.deltaTime * 2;

            transform.localScale = Mathfx.Hermite(Vector3.zero, scale, t);
            yield return(0);
        }
    }
Example #23
0
    public override void Loop()
    {
        UpdateFinalRotation();

        _rotationProgress += Time.deltaTime * Owner.BlackBoard.rotationSmoothInMove;
        _rotationProgress  = Mathf.Min(_rotationProgress, 1);
        Quaternion q = Quaternion.Slerp(_startRotation, _finalRotation, _rotationProgress);

        Owner.Transform.rotation = q;

        if (_moveOk && Owner.AnimEngine[_agentAction.data.animName].time > Owner.AnimEngine[_agentAction.data.animName].length * 0.1f)
        {
            float curSmooth = Owner.BlackBoard.speedSmooth * Time.deltaTime;
            Owner.BlackBoard.speed   = Mathfx.Hermite(Owner.BlackBoard.speed, _maxSpeed, curSmooth);
            Owner.BlackBoard.moveDir = Owner.Forward;

            float dist = Owner.BlackBoard.speed * Time.deltaTime;
            _moveOk = Move(Owner.BlackBoard.moveDir * dist, true);

            if (_hitTimer < Time.timeSinceLevelLoad) // 伤害结算计时
            {
                if (Owner.BlackBoard.desiredTarget != null && Owner.BlackBoard.desiredTarget.BlackBoard.IsAlive &&
                    Owner.BlackBoard.desiredTarget.BlackBoard.motionType != MotionType.ROLL &&
                    Owner.BlackBoard.desiredTarget.BlackBoard.invulnerable == false)
                {
                    if ((Owner.BlackBoard.desiredTarget.Position - Owner.Position).sqrMagnitude < Owner.BlackBoard.weaponRange * Owner.BlackBoard.weaponRange)
                    {
                        Owner.BlackBoard.desiredTarget.ReceiveDamage(Owner, WeaponType.Body, _agentAction.data.hitDamage, _agentAction.data);
                        //Owner.SoundPlayHit();
                    }
                }

                _hitTimer = Time.timeSinceLevelLoad + 0.75f;
            }
        }

        /*if (Effect == null && Time.timeSinceLevelLoad > TimeToStartEffect && Time.timeSinceLevelLoad < TimeToEndEffect)
         * {
         *  Effect = CombatEffectsManager.Instance.PlayWhirlEffect(Transform);
         * }
         * else if (Effect != null && Time.timeSinceLevelLoad > TimeToEndEffect)
         * {
         *  CombatEffectsManager.Instance.ReturnWhirlEffect(Effect);
         *  Effect = null;
         * }*/


        if (_timeToEndState < Time.timeSinceLevelLoad)
        {
            IsFinished = true;
        }
    }
Example #24
0
        private IEnumerator RotateAnimation(float startEuler, float endEuler, float costTime)
        {
            float degree = 0f;
            float delta  = 1f / costTime;

            while (degree < 1f)
            {
                transform.eulerAngles = new Vector3(0, 0, Mathfx.Hermite(startEuler, endEuler, degree));
                degree += Time.deltaTime * delta;
                yield return(null);
            }
            transform.eulerAngles = new Vector3(0, 0, endEuler);
        }
Example #25
0
    public IEnumerator Hide()
    {
        float t = 1;

        while (t > 0)
        {
            t -= Time.deltaTime * 2;

            transform.localScale = Mathfx.Hermite(Vector3.zero, scale, t);
            yield return(0);
        }
        gameObject.SetActive(false);
    }
Example #26
0
    private void LeavingUpdate()
    {
        var t = getT(timeLastState, timeToLeave);

        if (t >= 1.0)
        {
            current_state = StepCompletePanelState.GONE;
            timeLastState = Time.time;
            this.gameObject.SetActive(false);
        }
        Vector3 newPos = Mathfx.Hermite(rect3posOrig, startPos, t);

        rectTrans.position = newPos;
    }
 public void UpdateZoom()
 {
     if (_doZoom)
     {
         _elapsedZoomTime += Time.deltaTime;
         float value = Mathfx.Hermite(_initZoom, _endZoom, _elapsedZoomTime / _zoomTime);
         _cam.fieldOfView = value;
         if (_elapsedZoomTime >= _zoomTime)
         {
             _doZoom          = false;
             _cam.fieldOfView = _endZoom;
         }
     }
 }
Example #28
0
    //Moves into its split position, when we split the model
    public IEnumerator MoveToSplitPos()
    {
        float t = 0;

        while (t < 1)
        {
            t += Time.deltaTime;
            Vector3 pos;
            pos.x = Mathfx.Hermite(originalPos.x, targetPosObj.localPosition.x, t);
            pos.y = Mathfx.Hermite(originalPos.y, targetPosObj.localPosition.y, t);
            pos.z = Mathfx.Hermite(originalPos.z, targetPosObj.localPosition.z, t);
            transform.localPosition = pos;
            yield return(0);
        }
    }
Example #29
0
    public static IEnumerator HermiteScaleRealtime(Transform transform, Vector3 startScale, Vector3 endScale, float duration)
    {
        float startTime = Time.unscaledTime;

        while (Time.unscaledTime < startTime + duration)
        {
            float t = Mathf.Clamp01((Time.unscaledTime - startTime) / duration);
            t = Mathfx.Hermite(0.0f, 1.0f, t);
            if (transform != null)
            {
                transform.localScale = Vector3.Lerp(startScale, endScale, t);
            }
            yield return(null);
        }
    }
Example #30
0
 // Update is called once per frame
 void Update()
 {
     t += Time.deltaTime / fadeTime * dir;
     if (t > 1)
     {
         dir = -1;
         t   = 1;
     }
     else if (t < 0)
     {
         dir = 1;
         t   = 0;
     }
     color.a    = Mathfx.Hermite(0, 1, t);
     text.color = color;
 }