Unity Simple Functions (Update, Start, Fixed Update, LateUpdate)
Unity Simple Functions
Hello friends, in this post I will talk about a few functions in Unity that are useful for us, or rather, the simple and commonly used ones.Start Function
void Start(){
}
The Start function runs on the very first frame when the game starts, and does not run again until the game or scene restarts. It is used for the code that we want to execute as soon as the game launches.
Update Function
void Update(){
}
We use the Update function for code that runs every frame. For example, in a game running at 30 fps per second, the Update function runs 30 times.
Note: You will see FixedUpdate below. The difference between the Update and FixedUpdate functions is that Update runs with the fps of the game. For example, if the pc runs at 30 fps, it runs 30 times, if 60 fps, 60 times, if 10 fps, 10 times.
FixedUpdate Function
void FixedUpdate() {
}
The FixedUpdate function is also a continuously running function based on fps, but unlike Update, it runs at a fixed rate per second. That is, whether the pc is at 30 fps or 60 fps, it always runs at a constant rate.
FixedUpdate is generally used for physical activities (Collisions, movement, ...).
LateUpdate Function
void LateUpdate(){
}
The LateUpdate function is generally the last update function to run. We can think of it as the last frame, but in reality, it is an Update function that runs after the processes in functions like Update and FixedUpdate have been carried out and completed.
In general, the places where we use this are simpler places or places where it is not necessary to be instant.


Yorum Gönder