本文介绍了检查情况,并要求连续法延迟团结的时期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想代码来检查,如果目标是活的,如果是它拍摄。
我要检查它所有的时间,和拍摄的时候,唯一的问题是,支票可以在任何时候作出ü希望,但投篮必须要有每秒火限制。我的意思是ü检查目标所有的时间,但是当u决定拍摄,子弹将火陆续有一些延误。而且当u意识到,目标是死你停止在同一时间拍摄的。

 无效更新()
{
StartCoroutine(拍摄(currentTarget当前,1F));
}

IEnumerator的拍摄(撞机currentTarget当前,浮动delayTime)
{
收益回报新WaitForSeconds(delayTime);
如果(currentTarget当前!= NULL)
{
......
}
}

这代码开始拍摄,但根据拍摄之间没有延迟。


解决方案

  InvokeRepeating(PossiblyShoot,1F,1F); 

私人无效PossiblyShoot()
{
1.检查,如果它在它存在的拍摄,如果目标仍然存在
2.
}


I want code to check if target is alive, and if yes shoot at it.I want to check it all the time, and shoot all the time, The only problem is that checks can be made anytime u want, but shooting must have limits of fire per second. I mean u check the target all the time, but when u decide to shoot, bullets will fire one after another with some delays. And also when u realize that target is dead u stop shooting at the same time.

void Update()
{
   StartCoroutine(Shoot(currentTarget, 1f));
}

IEnumerator Shoot(Collider currentTarget, float delayTime)
{
    yield return new WaitForSeconds(delayTime);
    if (currentTarget != null)
    {
         .......
    }
}

This code starts to shoot but with no delays between shooting.

解决方案
InvokeRepeating( "PossiblyShoot" , 1f, 1f );

private void PossiblyShoot()
   {
   1. check if target still exists
   2. if it exists shoot at it
   }

这篇关于检查情况,并要求连续法延迟团结的时期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 23:31