@GreatRash

Можно ли порешать коллизии в цикле, а не при каждом фрейме?

Метод OnCollisionStay запускается каждый фрейм, а мне надо запустить его внутри Start. Можно ли это сделать?
  • Вопрос задан
  • 2806 просмотров
Пригласить эксперта
Ответы на вопрос 1
AlieNCrazY
@AlieNCrazY
Можно использовать Coroutine

docs.unity3d.com/Documentation/Manual/Coroutines.html
d.pr/i/1cJW
This can be used as a way to spread an effect over a period time but it is also a useful optimization. Many tasks in a game need to be carried out periodically and the most obvious way to do this is to include them in the Update function. However, this function will typically be called many times per second. When a task doesn't need to be repeated quite so frequently, you can put it in a coroutine to get an update regularly but not every single frame. An example of this might be an alarm that warns the player if an enemy is nearby.

OnCollisionStay can be a co-routine, simply use the yield statement in the function.
docs.unity3d.com/Documentation/ScriptReference/Mon...
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы