Пример #1
0
    void Run()
    {
        if (!m_animation.IsPlaying("run"))
        {
            m_animation.CrossFade("run");
        }

        bool ok = GridUtility.MoveToTarget(m_finder, ref m_transform, m_speed * Time.deltaTime, 30);

        if (ok)
        {
            if (!m_finder.HasPath())
            {
                m_currentAction = Idle;
            }
            return;
        }

        if (!isControl)
        {
            m_currentAction = Idle;
        }
        else
        {
            ok = m_finder.BuildPath(GridUtility.VectorToPath(m_transform.position), GridUtility.VectorToPath(m_destination), 60, true, false, false);
            if (!m_finder.HasPath() || !ok)
            {
                m_currentAction = Idle;
            }
        }
    }