Beispiel #1
0
        private void FixedUpdate()
        {
            if (!isEating)
            {
                return;
            }

            float t    = (Time.time - eatStartTime);
            float dist = Vector3.Distance(Graviy.MouthPosition, transform.position);

            if ((t >= eatTime) ||
                ((t >= eatMinTime) &&
                 (dist <= EatDistance)))
            {
                // 食べる
                Graviy.instance.EatDone(this);
                GameParams.AddScore(point);
                GameParams.AddLife(heal);
                Destroy(gameObject);
                return;
            }

            t = Mathf.Clamp01(t / eatTime);

            Vector3 next = Vector3.Lerp(transform.position, Graviy.MouthPosition, t);
            Vector3 move = (next - transform.position) / Time.fixedDeltaTime;

            rb.velocity = move;
        }