Exemplo n.º 1
0
        void FixedUpdate()
        {
            if (state == StateType.Spawn)
            {
                return;
            }

            switch (state)
            {
            case StateType.Fly:
                if (transform.position.y - startY > removeHeight)
                {
                    Destroy(gameObject);
                }
                break;

            case StateType.Hold:
                lifeTime -= Time.fixedDeltaTime;
                if (lifeTime <= 0f)
                {
                    state = StateType.Fall;
                    Vector3 v = rb.velocity;
                    v.Set(0f, fallSpeed, 0);
                    rb.velocity = v;
                }
                break;

            case StateType.Fall:
                // 消す確認
                Vector3 origin = boxCollider.bounds.center;
                origin.y = boxCollider.bounds.max.y;
                GameObject go = PhysicsCaster.GetGroundWater(origin, Vector3.up, 1f);
                if (go != null)
                {
                    Destroy(gameObject);
                }

                break;
            }
        }