Posts

Showing posts from February, 2022

LOD

Image
 LOD     LOD refers to Level of Detail. It is a performance saving technique employed by Unity. When an object is close to the camera, the geometry of the object is rendered at full resolution. The resolution of the geometry falls as the distance from the camera increases. Setting up LOD in Unity     It is best practice to attach the LOD Group component to an empty parent gameObject, and have the different LOD levels be children of it. Setting up LOD levels for a Sphere:     1. Create a sphere in Unity. This sphere is pretty high res, so if we have multiple of these spheres in our Game world, our GPU won't be too happy about it.      2. Now we create a lower resolution sphere inside of Blender. Open the default scene and delete the cube that comes along with it. Add an icosphere using SHIFT + A. In the modifier settings tab, create a subdivision surface. set the Levels Viewport to 2.              3. Imp...

Grounded Checks in Unity

Image
  Grounded Checks in Unity DOOM-style Game Solution     If our game is like DOOM, that is, the ground is a horizontal flat plane, the solution for our grounded check is pretty easy.  THE SETUP:      Create a cube and position it arbitrarily on a plane with default Transform. Create a script called GroundCheck and attach it to the cube. THE LOGIC:          If the y-coordinate of the cube becomes less than or equal to 0.5, this means that our cube is touching the ground plane. Else, the cube is airborne. SCRIPTING:          Save the script and play the game. Try moving the cube vertically and observing the messages that are logged to the console. The Physics.CheckSphere Solution     The Physics.CheckSphere() is a handy function we can use to perform ground checks. The function returns a bool, and accepts two parameters, the center of the sphere and its radius THE SETUP:      ...