Ejemplo n.º 1
0
    private IEnumerator WalkBehaviors()
    {
        DoRandomNonFlyingAnimation();
        yield return(new WaitForSeconds(3));

        FaceRandomGroundDirection();

        float TimeWalking = 0;

        dragon.Walk();
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            transform.position += transform.forward * WalkSpeed * Time.deltaTime;

            TimeWalking += Time.deltaTime;
            if (TimeWalking > 4f) // time the animation takes
            {
                int WhatToDoNext = Random.Range(0, 20);
                if (WhatToDoNext <= 4)
                {
                    State = (DragonState)Random.Range(0, 5);
                    yield return(null);
                }
                else
                {
                    dragon.Walk();
                    TimeWalking = 0;
                }
            }
        }
    }