示例#1
0
    //public void resetInterpolationTime()
    //{
    //	m_elapsedTime = 0.0f;
    //}

    // Updates the transform based on the behavior.
    // Returns true if the state of the transform changed.
    public virtual bool tryMove(Transform transform, float deltaTime = 0.0f)
    {
        Vector3 prevPosition = transform.position;
        Vector3 newPosition  = prevPosition;                                                                    //TODO: FIX THIS TO ALLOW UPDATING OVER THE RIGIDBODY FORCE APPLICATION TIMER UPDATING.

        // If an interpolator was given, use the interpolated position.
        if (m_interpolator != null)
        {
            if (m_interpolationTime < m_interpolator.duration)
            {
                m_interpolationTime = Mathf.Min(m_interpolationTime + deltaTime, m_interpolator.duration);
                newPosition         = InterpolationHelper.getInterpolatedVector3(m_interpolator, m_interpolationTime);
            }
        }
        // Otherwise get the final target position.
        else
        {
            newPosition = getTargetPosition(transform, deltaTime);
        }

        //if(m_moveRelative)
        //{
        //	transform.forward =
        //}
        //else
        //{
        transform.position = newPosition;
        //}
        return(true);        //!prevPosition.Equals(transform.position);
    }