c#, unity, unity tips and tricks, Unity Tutorials, unity3d

Difference Between Destroy and DestroyImmediate Unity Functions

Objective : Objective of this Tutorial is to understand diffence between Destroy and DestroyImmediate unity function Purpose of both function is same, to destoy gameobject, but there is very small difference, which is very crucial to understand, wrong use of these function can cause your app to crash So first of all little bit of theory and then some code Destroy() :  This just destroy the game object passed as parameter.  It set all the references to that game object to null at the end of frame. Syntax: Destroy(myGameObject); Let see it in code: Create new script and add this code and add it to Main Camera and click play, and just left click to create new game object and press space bar to destroy the game object and check the log in console window you will notice that first log print the status “true“, and second log print the name of currObject which…

unity, unity tips and tricks, Unity Tutorials, unity3d

Difference Between Update and FixedUpdate

Objective : The objective of this post to understand the difference between Update and FixedUpdate unity function, and their uses. Update : Update is called once per frame, so if the game is running at 24 fps, then this will be called 24 times in a second. As we know game never run at constant frame rate because of several reason, so update will not be called on a regular timeline, means the time between update calls may be different. Uses: Update is used for moving non physics objects. Update is used for receiving Input. Update is used for simple timer. Fixed Update: As it name suggests this will be called after fixed time duration, so time duration between two consecutive calls is always same unlike of Update where this may vary.  Uses : This is commonly used for performing physics related task, like applying force on rigidbody. Now let’s see this in example Create a…