c#, Coroutines, unity

Coroutines in Unity3D

Objective : The objective of this blog is to learn about Coroutines and its uses in Unity3D. Introduction : Before jumping to Coroutines, let’s discuss why it is required ? and what makes it a powerful feature that can do wonder in unity. Unity is frame based.Unity does things each frame. Many processes in games take place over the course of multiple frames.Sometimes we got a dense process that takes a long time to finish, so during this time your game will run at low FPS(frames per second). so we have to find a way so that this process will not impact our game fps. One way is run this process on another thread, instead on the main thread. But Unity is single threaded. There is one main loop of Unity and all those functions that you write are being called by the same main thread in order. we can verify…

unity, Unity Tutorials

Delegates and Events in Unity

  Objective: The Objective of the tutorial is to understand how to use and implement Delegates and Events in Unity. If you enjoyed my previous tutorial about Singleton, this is second of many tutorials to learn how to use unity to full potential and write efficient code in Unity. Introduction : Delegates and Events is very powerful feature of C# programming language, it helps to write efficient and clean code in unity. Delegate : A Delegate is a reference pointer to a method. It allows us to treat method as a variable and pass method as a variable for a callback. When it get called , it notifies all methods that reference the delegate. The basic idea behind them is exactly the same as a subscription magazine. Anyone can subscribe to the service and they will receive the update at the right time automatically. I know at this time everything seems very…

c#, unity, Unity Tutorials

Singleton : Implementation in Unity3d C#

Objective : Singleton is a very complex topic, In this, we try to understand basics and various implementation of Singleton in Unity3d using C#. Intro: Singleton is a basic Design Pattern. Classes implementing Singleton pattern will ensure that only one instance of the object ever exists at any one time. It is recommend using Singletons for things that do not need to be copied multiple times during a game.This is great for controller classes like GameManager or AudioController. Implementation: There are several ways of implementing Singleton in Unity, we will some of the implementation in this tutorial Simplest Implementation Above code is the simplest implementation of Singleton, but there are some issues which we have to address Singleton is not persistent across the Unity scenes. All the executable code must be attached to GameObject in the hierarchy. It is not recommended to call SingletonController.Instance in any Awake() method because, since we don’t know the…

assetstore, unity, unity3d

Must Have Free Assets From Unity AssetStore

Objective : In this we are creating list of some must have free assets from Unity AssetStore. Unity Assets List :   Cameras : RTS camera : Best Camera assets in Unity AssetStore. EZ Camera Shake : The EZ Camera Shake system provides a versatile implementation of procedural camera-shaking animation. GhostFreeRoamCamera : Free flying ghost roaming camera, in a FPS style. AI : RAIN AI for Unity : A very powerful A* plugin for Unity 4 & 5. Uses tree binding. Unity Movement AI : A library of steering behaviors to help your NPCs move around your game. TopDown AI : This is an example of Top Down Shooter AI for the Unity game engine. Animations : TakeDown Animations : 12 Takedowns animations package. Magic Pack : 55 awesome animation from mixamo. Animated Horse : Beautifully Animated Horse. Warrior Pack Bundle 2 FREE : This asset contains 3 animations for each of the 4 warriors in the pack. Huge FBX Mocap Library part 1 : It contains 2,534 mocap…

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…

c#, unity, Unity Interview Questions, Unity Tutorials, unity3d

Unity Interview Questions

In this, I am going to list some of the very commonly asked interview questions for unity developer profile. Unity Engine Specific Question : Difference between Update,Fixed Update and Late Update. What is Prefabs in Unity 3D? What is the use of AssetBundle in Unity? What is difference between Resources and StreamingAssets Folder. What is Batching and what is the use of Batching? Difference between Destroy and DestroyImmediate unity function Difference between Start and Awake Unity Events What is the use of deltatime? Is this possible to collide two mesh collider,if yes then How? Difference between Static and Dynamic Batching. What is the use of Occlusion Culling? How can you call C# from Javascript, and vice versa? Arrange the event functions listed below in the order in which they will be invoked when an application is closed: Update() OnGUI() Awake() OnDisable() Start() LateUpdate() OnEnable() OnApplicationQuit() OnDestroy() C# related Questions :  Difference between…

Google Cardboard, Virtual Reality, VR

How to Build Google Cardboard VR Game using Unity part -1

unity_googlecardboard

Unity made it very easy to create VR apps, and with cardboard, it is just super easy. Unity 5.1 onwards contains built-in support for certain VR devices, but for that, you require Unity pro licence.   So Why Cardboard ? Because it is cheapest VR Device available in the market. it cost you only $10- $20, and you do not need Unity pro licence for that. other options for virtual reality devices                                          all are very expensive and some are not easily available to the user. On the other hand google Cardboard works with most modern Android phones and iPhone. Phones need to be running Android 4.1 (Jelly Bean) or above. Ideally should have a gyroscope, most important there are tons of apps available. Prerequisites Unity – At least v5.1 is…