V
V
Vlad1222021-08-20 16:45:43
C++ / C#
Vlad122, 2021-08-20 16:45:43

How heavy is the processor load of checking the if statement?

I do not really understand what is in the script and how much it can load the processor. Those. what is better to constantly get the value of a variable from another script using GetComponet (in the FixedUpdate function) or put it into a condition to put it in a repeating time frame. Does it cost the processor that I assign a value to a variable that it already has (in the FixedUpdate function). If so, will the load be reduced when inserting this variable into an if, so that the value is assigned to the variable only if it is not already equal to it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2021-08-20
@HemulGM

The if itself does not load, but your check before assignment will be performed for some time

I
Ilya, 2021-08-20
@sarapinit

Most likely, just assignment will be faster.
But it is not important. Most likely, this will not be the most expensive place in the program. You need to learn how to use the profiler, and come to micro-optimizations when there is no other way out

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question