[Unity][AI]update函数怎么实现延迟

在敌人AI 控制 的组件中。经常在update 函数中,控制敌人AI 行为。

有的时候需要 用到 延迟。以下可以实现,仅供参考。

update()

{

if (...)//条件判断
            {
                Debug.Log("   7777777777 ");
                m_timer += Time.deltaTime;
                //m_timer += Time.time;
                //timeSpend += Time.deltaTime * time_int;
                //播放重新装弹 的动画

animator.....


                if (m_timer >=3)//延迟 3秒
                {
                    Debug.Log("   7777777777 //11");
                    reload();
                    m_timer = 0;
                }
            }

}

参考资料:

1.转:Unity延时功能的几种实现

2.

3.

4.

猜你喜欢

转载自blog.csdn.net/BuladeMian/article/details/81289084