Exemplo n.º 1
0
        void LateUpdate()
        {
            if (!m_Inited || m_FollowTargetTrans == null)
            {
                return;
            }

            m_FollowTargetPos = m_FollowTargetTrans.TransformPoint(m_FollowTargetOffset);

            Vector3 offset = m_ExpectedOffset;
            bool    avoid  = AvoidObstruction(ref offset);

            if (followDumpping.Used)
            {
                Vector3 currOffset = transform.position - m_FollowTargetPos;
                if (CocoMath.Approximately(currOffset, offset, 0.0001f))
                {
                    return;
                }

                float t = followDumpping.Value * Time.deltaTime;
                offset = !avoid?Vector3.Slerp(currOffset, offset, t) : Vector3.Lerp(currOffset, offset, t);
            }

            transform.position = m_FollowTargetPos + offset;
            transform.LookAt(m_FollowTargetPos);

            if (OnMoveEvent != null)
            {
                OnMoveEvent(this);
            }
        }
Exemplo n.º 2
0
 protected override bool IsNonNullDifferent(Vector3 value1, Vector3 value2)
 {
     return(!CocoMath.Approximately(value1, value2, m_ErrorRange));
 }