I
I
Ilya Smirnov2017-05-30 20:36:43
C++ / C#
Ilya Smirnov, 2017-05-30 20:36:43

How can I make a function run only once and not every frame in C#?

the function OnTriggerEnter and OnTriggerExit emits values ​​every frame, but how to make it emit values ​​only onceQ2K5yVwf433Pqr.png5510eef057.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Di-Roll, 2017-05-31
@Googoogoogoose

Add a condition.

bool fired = false;

void OnCollisionEnter(Collision col) 
{
   if(!fired)
   {
      // код
      fired = true;
   }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question