예제 #1
0
        /// <summary>
        /// 判定前の更新
        /// </summary>
        void FixedUpdate()
        {
            // 親の移動量を取得
            var v = transform.parent.transform.position - _old;

            transform.position = transform.position + v * Time.deltaTime;
            _old = transform.parent.transform.position;

            if (_ride)
            {
                // 乗る(親子関係)
                if (_ride.transform != transform.parent)
                {
                    SetParent(_ride.transform.parent.transform);
                }
            }
            else
            {
                if (_parent)
                {
                    SetParent(_parent);
                }
            }

            if (_fall && (!_ride))
            {
                // 落ちた
                StartCoroutine(this.Fall());
            }

            _fall = false;
            _ride = null;
        }
예제 #2
0
        /// <summary>
        /// 当たっているとき
        /// </summary>
        /// <param name="other"></param>
        void OnTriggerStay2D(Collider2D other)
        {
            // 足元で判定
            var myBounds = Collider.bounds;

            if (other.bounds.Contains(myBounds.center - new Vector3(0.0f, myBounds.extents.y, 0.0f)))
            {
                if (other.tag == "Hole")
                {
                    _fall = true;
                }

                var ride = other.GetComponent <Element.RideFloor>();
                if (ride)
                {
                    _ride = ride;
                    _fall = false;
                }
            }
        }