<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Giorgi Eliozashvili on Medium]]></title>
        <description><![CDATA[Stories by Giorgi Eliozashvili on Medium]]></description>
        <link>https://medium.com/@ilivhsazoile.g?source=rss-70d00fa60af5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*E33ebGs0NX696eyEsjjYVw.jpeg</url>
            <title>Stories by Giorgi Eliozashvili on Medium</title>
            <link>https://medium.com/@ilivhsazoile.g?source=rss-70d00fa60af5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:00:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ilivhsazoile.g/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is a struct, and how to serialize it in the inspector]]></title>
            <link>https://medium.com/@ilivhsazoile.g/what-is-a-struct-and-how-to-serialize-it-in-the-inspector-275c001d6a22?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/275c001d6a22</guid>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 16:41:25 GMT</pubDate>
            <atom:updated>2026-08-16T16:49:55.489Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*esPwxaALrgY02EP1fYmxdw.png" /></figure><blockquote>A structure type (or <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct">struct </a>type) is a value type that can encapsulate data and related functionality.</blockquote><p>A <em>struct </em>is a simple container that binds several variables into a single entity.</p><p>Main difference between struct and class is where they are stored:</p><p><em>struct </em>(value type) — is stored in <em>Stack</em>. How does that work? Passed by value, when you assign a <em>struct </em>to a new variable, <em>C#</em> creates its standalone clone. In <strong>Unity</strong>, creation and deletion of <em>struct </em>occur instantly and do not load the <strong>Garbage Collector</strong>.</p><p><em>class </em>(reference type) — is stored in <em>Heap</em>. How does that work? Passed by reference. Several variables can refer to the same object in memory. In <strong>Unity </strong><em>class </em>instances require heap allocation, and when they are destroyed, the <strong>Garbage Collector</strong> is triggered, which can lead to micro-freezes during gameplay.</p><p>Yesterday I started making a small project to level up my skills, a simple slot machine that outputs 3 random fruits. You pull the lever and magic happens (<strong><em>do not gamble, kids</em></strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*EOOkWuwPs-rtQpWuR0bhuw.png" /></figure><p>I needed some structure that allows me to modify multipliers and payouts through the inspector, and I found an attribute<em> [System.Serializable]. </em>By default, <strong>Unity </strong>cannot see a custom <em>struct </em>in the inspector, so you can’t simply make a <em>struct [SerializeField]. </em>Here’s an example of how to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*t4F10gssMabWv7Lw7_4VMQ.png" /></figure><p>And this is what it looks like in the inspector. I needed a key — value type of data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*XcOB9cdvy_wzhUYvLbUHDg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=275c001d6a22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity ScriptableObject]]></title>
            <link>https://medium.com/@ilivhsazoile.g/unity-scriptableobjects-13328c63568b?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/13328c63568b</guid>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 08:34:05 GMT</pubDate>
            <atom:updated>2026-07-19T08:35:57.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*A933Roa8l5TwebTWeGRhbQ.png" /></figure><p>When you first make a weapon in a shooter game, you usually give it the standard <em>MonoBehaviour </em>script and write everything there: damage, fire rate, ammo, shooting logic, etc. But when you start adding new weapons, lots of data duplication appears. Every prefab holds a copy of the same data. To solve this, <strong>Unity </strong>has a feature called <a href="https://docs.unity3d.com/Manual/class-ScriptableObject.html"><em>ScriptableObjects</em></a>.</p><p>According to Unity documentation, this is the official use case of <em>ScriptableObjects</em>:</p><blockquote>Saving and storing data during an Editor session</blockquote><blockquote>Saving data as an asset in your project to use at runtime</blockquote><p><em>ScriptableObject </em>is an independent container for saving data. Its main difference from the usual <em>MonoBehaviour </em>is that it does not need to be attached to a GameObject in the scene.</p><p>Let’s see the example of my basic weapon <em>ScriptableObject</em>:</p><pre>using UnityEngine;<br><br>[CreateAssetMenu(fileName = &quot;WeaponSO&quot;, menuName = &quot;Scriptable Objects/WeaponsSO&quot;)]<br>public class WeaponSO : ScriptableObject<br>{<br>    public Weapon WeaponPrefab;<br>    public ParticleSystem HitVFX;<br><br>    public int Damage;<br>    public float FireRate;<br>    public bool IsAutomatic;<br>    public bool CanZoom;<br>    public float ZoomAmount;<br>    public float ZoomRotationSpeed;<br>}</pre><p><em>ScriptableObject</em>-s are inheriting from <strong>ScriptableObject </strong>instead of <em>MonoBehaviour</em>.</p><p>Let’s break this example down:</p><p>1. <strong>[CreateAssetMenu]</strong> allows us to create a <em>ScriptableObject </em>file in our project&#39;s folder.</p><p>2. Inside the class, there are no <em>Start()</em> nor<em> Update()</em> methods. Just pure data that you can manipulate through <strong>Unity Inspector</strong>. And this is how it looks in <strong>Inspector</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*FO0F8_-0xTCwaJ04D2GAgw.png" /></figure><p>So you can have separate weapon <em>ScriptableObjects </em>in your project and manipulate them more clearly and easily.</p><p>In summary, <em>ScriptableObject </em>is a perfect tool for data management, separating data (<em>ScriptableObject</em>) and logic (<em>MonoBehaviour</em>), making your project cleaner and easily manageable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13328c63568b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Unity NavMesh]]></title>
            <link>https://medium.com/@ilivhsazoile.g/simple-unity-navmesh-0c158ef97da1?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c158ef97da1</guid>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 10:15:33 GMT</pubDate>
            <atom:updated>2026-07-04T10:15:33.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*KMSPIUECglCi0Fkw5MBLuA.png" /></figure><p>Let’s build a simple AI follower using <strong>Unity</strong>’s built-in component <em>NavMesh</em>.</p><p>We will use <em>NavMesh Agent</em> and <em>NavMesh Surface </em>for this simple example.</p><p><em>NavMesh Surface</em> — is a component that scans the surface and “bakes” it in a way that our Agent can walk on it.</p><p><em>NavMesh Agent</em> — is a component that you give to your <em>“follower”</em> (any kind of follower, can be an enemy or just a cute minion that follows you around). It knows its <em>height </em>and <em>radius </em>and can go around obstacles.</p><p>With our <em>Agent </em>and <em>Surface, </em>we need to make a short script that tells our <em>Agent </em>to move and follow our target, in this case, the Player.</p><p>But before that, let’s dive into some <em>NavMesh </em>settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*EsYkmOKbSbl6maysKaheUg.jpeg" /></figure><p>In this <em>NavMesh Surface</em>, we are interested in two parameters.</p><ul><li><em>Agent Type —</em> is Robot, because it knows what kind of agent will walk around on the surface</li><li><em>Include Layers —</em> is where you specify which <em>GameObject </em>layers the <em>NavMesh Surface</em> will include during the baking process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*kYOGNfJue02vLc3KGQ4VJA.png" /></figure><p>This is <em>NavMesh Agent</em> settings, where you can choose <em>Agent Type</em> and give it some basic and pretty straightforward options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*zFjnNsQLb3t33S0Cu-t3pw.png" /></figure><p>This is <em>Navigation </em>of the Agent. Let’s find out what those options are because I find it very interesting.</p><ul><li><strong><em>Radius</em></strong> — defines agent’s <em>*drum roll*</em> radius! We determine how wide our agent is. When baking the mesh, <strong>Unity </strong>will offset all walls and corners by this amount to prevent your agent from rubbing its sides against textures when walking or getting stuck in narrow passages.</li><li><strong><em>Height</em></strong> — defines agent’s height. Allows <strong>Unity </strong>to calculate whether the agent can fit under low obstacles, bridges, or ceilings. If the clearance height is less than 1, the mesh underneath it will not be baked.</li><li><strong><em>Step Height</em></strong> — determines the maximum height of a stair or threshold of an obstacle that the agent can climb. We want to make sure that this option is always lower than <em>Height</em>.</li><li><strong><em>Max Slope</em></strong> — the maximum degree of surface slope that the agent is physically capable of walking up or down.</li><li><strong><em>Drop Height </em></strong>— determines the maximum height from which agent can jump. In our case 9. If the actual height of an object is more than 9 then agent will not drop down.</li><li><strong><em>Jump Distance</em></strong> — is the maximum horizontal distance that agent can jump.</li></ul><p>Now let’s check the code out:</p><pre>using UnityEngine;<br>using UnityEngine.AI;<br>using StarterAssets;<br><br>public class Robot : MonoBehaviour<br>{<br>    private FirstPersonController _player;<br>    private NavMeshAgent _agent;<br><br>    private void Awake()<br>    {<br>        _agent = GetComponent&lt;NavMeshAgent&gt;();<br>    }<br><br>    private void Start()<br>    {<br>        _player = FindAnyObjectByType&lt;FirstPersonController&gt;();<br>    }<br><br>    private void Update()<br>    {<br>        _agent.SetDestination(_player.transform.position);<br>    }<br>}</pre><p>To use <em>NavMesh </em>we need to import its <em>namespace</em>, which is <em>UnityEngine.AI</em>. I also use <em>StarterAssets </em>for this project for a premade first-person controller from <strong>Asset’s Store</strong>.</p><p>First, we need to declare and cache our variables. We retrieve the <em>_agent </em>component in <em>Awake()</em> since this script is attached directly to the Robot game object. Then, we find the <em>_player</em> in <em>Start()</em>. In the <em>Update()</em>, we call the built-in <em>SetDestination() </em>method, which takes player&#39;s <em>Vector3</em> position. Once the game starts, the agent will dynamically pursue the player wherever they go.</p><p>And that’s it. This is how to make a simple AI follower in <strong>Unity</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c158ef97da1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mathf.Lerp() Making dynamic camera zoom in Unity using Coroutines]]></title>
            <link>https://medium.com/@ilivhsazoile.g/mathf-lerp-making-dynamic-camera-zoom-in-unity-using-coroutines-a6bf37d23df4?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6bf37d23df4</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Thu, 25 Jun 2026 16:34:38 GMT</pubDate>
            <atom:updated>2026-06-25T16:34:38.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*5AgFJ5cq0TzTFL1B6OaTVw.png" /></figure><p>The easiest way to show Player how fast his character is moving is by using camera zoom. For example, if Player is going very fast, camera is zoomed out, FOV is increased, and a feeling of swiftness appears.</p><p>We want the camera zoom to be smooth, not instantaneous. For this <em>Mathf.Lerp()</em>, <em>Coroutine </em>and <em>while loop</em> come in handy.</p><p>The <em>Mathf.Lerp(A, B, t)</em> function stands for <strong>linear interpolation</strong>. It takes a starting value - <em>A</em>, a final target - <em>B</em>, and returns a point between them based on the <em>t </em>parameter (a percentage of the path from 0 to 1).</p><p>If we want the FOV change to take exactly the time we specify (for example, half a second), we can’t simply pass random numbers. We need a strict timer.</p><p>To achieve this, a <em>while loop</em> is created inside the <em>Coroutine</em>, which calculates what fraction of the total animation time has elapsed each frame.</p><p>Let’s check the realisation:</p><pre>using System;<br>using UnityEngine;<br>using System.Collections;<br>using Unity.Cinemachine;<br><br>public class CameraController : MonoBehaviour<br>{<br>    [SerializeField] private float minFOV = 40f;<br>    [SerializeField] private float maxFOV = 80f;<br>    [SerializeField] private float zoomDuration = 0.5f;<br>    [SerializeField] private float zoomSpeedModifier = 2f;<br><br>    private CinemachineCamera _camera;<br>    private Coroutine _zoomCoroutine;<br><br>    private void Awake()<br>    {<br>        _camera = GetComponent&lt;CinemachineCamera&gt;();<br>    }<br><br>    // Called externally to trigger the camera zoom effect<br>    // In this project, it&#39;s invoked within the level generation script<br>    public void ChangeCameraFOV(float speedAmount)<br>    {<br>        if (_zoomCoroutine != null)<br>            StopCoroutine(_zoomCoroutine);<br><br>        _zoomCoroutine = StartCoroutine(CameraFOVChange(speedAmount));<br>    }<br><br>    private IEnumerator CameraFOVChange(float speedAmount)<br>    {<br>        // Store the initial FOV before starting the interpolation<br>        var startFOV = _camera.Lens.FieldOfView;<br>        <br>        // // Calculate target FOV and clamp it to prevent visual artifacts or unexpected behavior<br>        var targetFOV = Mathf.Clamp(startFOV + speedAmount * zoomSpeedModifier, minFOV, maxFOV);<br><br>        var elapsedTime = 0f;<br>        while (elapsedTime &lt; zoomDuration)<br>        {<br>            elapsedTime += Time.deltaTime;<br><br>            // Calculate the normalized time (0 to 1) <br>            // by dividing elapsed time by total duration<br>            float t = elapsedTime / zoomDuration;<br><br>            _camera.Lens.FieldOfView = Mathf.Lerp(startFOV, targetFOV, t);<br>            // Pause execution and resume on the next Update cycle<br>            yield return null;<br>        }<br><br>        // Ensure the camera snaps precisely to the target FOV<br>        // avoiding float inaccuracies<br>        _camera.Lens.FieldOfView = targetFOV;<br>        _zoomCoroutine = null;<br>    }<br>}</pre><p>The <em>Coroutine + While Loop + Mathf.Lerp</em> combination is a great pattern for implementing any smooth time change in <strong>Unity</strong>. Once you understand how the time step <em>t</em> is calculated, you can use this pattern for anything from smooth platform movement to dissolving objects upon destruction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6bf37d23df4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Physics Material]]></title>
            <link>https://medium.com/@ilivhsazoile.g/unity-physics-material-614a4c9b5c3f?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/614a4c9b5c3f</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 10:13:13 GMT</pubDate>
            <atom:updated>2026-06-23T10:13:13.611Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*S7U2Y7LQ2YETQO2FSfJlsw.png" /></figure><blockquote>The <a href="https://docs.unity3d.com/Manual/class-PhysicsMaterial.html"><strong>Physics Material</strong></a> is a material asset that you can place on a <strong>GameObject</strong>. The material defines properties on the <strong>collider</strong>’<strong>s</strong> surface, such as friction and bounciness.</blockquote><p>To create <em>Physics Material</em>, simply right-click in <em>Project </em>folder, hover over <em>Create, </em>and at the bottom, you will see Physics Material. After creating it, you need to drag and drop the material to <em>GameObject </em>of your choice that has a collider on it.</p><p>NOTE: If collider has no <em>Physics Material </em>on it<strong><em> (None (Physics Material))</em></strong> then it has default <em>Physics Material</em> properties.</p><p>Now, let’s describe those properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*2Y1ZGXTxclDe-McifRJmaw.png" /></figure><p><strong>Dynamic Friction:</strong> works when an object is already in motion on a surface and determines how fast it will stop sliding. Value of <strong><em>0 </em></strong>will make an object act like a hockey puck, and value of <strong><em>1</em></strong> will make an object stop sliding almost immediately.</p><p><strong>Static Friction:</strong> is the frictional force that must be overcome to move a stationary object. Imagine a wardrobe that you must move. It is always harder to move a heavy wardrobe from its place (high static friction) than to push it further once it has already moved (dynamic friction). Value of <strong><em>0</em></strong> means that any smallest push will make an object move.</p><p><strong>Bounciness:</strong> is pretty straightforward. This option determines how well an object will bounce. Value of <strong><em>0 </em></strong>means an object has no bouncing properties, imagine you drop a block of wet cheese, while value of <em>1 </em>is a perfect bouncing ball.</p><p><strong>Friction Combine:</strong> determines the friction between two touching surfaces.</p><ul><li><strong>Average:</strong> <em>arithmetic </em>mean between two objects<em>.</em></li><li><strong>Minimum:</strong> picks the lowest value of two objects.</li><li><strong>Maximum:</strong> pick the highest value of two objects.</li><li><strong>Multiply:</strong> values are multiplied by each other.</li></ul><p><strong>Bounce Combine:</strong> works the same way as F<strong>riction Combine</strong>, but with bounciness and has the same dropdown options.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=614a4c9b5c3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quaternion.LookRotation & Vector subtraction]]></title>
            <link>https://medium.com/@ilivhsazoile.g/quaternion-lookrotation-vector-subtraction-f4cdc4765974?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4cdc4765974</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 18:05:43 GMT</pubDate>
            <atom:updated>2026-06-12T18:05:43.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*EcGnO7jElJ4IxUkmKX1C0A.png" /><figcaption>Quaternion.LookRotation</figcaption></figure><p>Today, we talk about two very interesting features, vector subtraction and <em>Quaternion.LookRotation</em> on a missile example.</p><p>First, we need to find a direction from point A to point B, and we do this by subtracting two Vectors:</p><blockquote>Direction = Target position — Missile position</blockquote><p>Then, we translate the direction into rotation. In Unity we use <em>Quaternions</em> to handle rotations.</p><p>There is a good method that Unity offers named <em>Quaternion.LookRotation(). </em>It takes direction and calculates rotation around <em>Y</em> axis (which is sky by default).</p><pre>private void AimMissile()<br>{<br>    foreach (var missile in missiles)<br>    {<br>        // Distance/Direction between missile and target<br>        var shootingDistance = target.position - missile.transform.position;<br>        // Quaternion.LookRotation takes shootingDistance Vector3<br>        // to rotate missile in target&#39;s direction<br>        var missileRotationToTarget = Quaternion.LookRotation(shootingDistance);<br>        // And finally update missile transform<br>        missile.transform.rotation = missileRotationToTarget;<br>    }<br>}</pre><p>So, every frame, this method executes a loop throughout missiles array. Every missile individually calculates its own and target coordinates. <em>LookRotation </em>understands the angle at which to rotate each missile. As a result, even if the target shifts to the side, all missiles synchronously adjust their course in flight.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4cdc4765974" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mathf.Exp()]]></title>
            <link>https://medium.com/@ilivhsazoile.g/day-6-of-unity-game-dev-12-06-2026-8f7c680f5a53?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f7c680f5a53</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 16:11:38 GMT</pubDate>
            <atom:updated>2026-06-12T17:12:05.215Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*sqP-0Kq6Wit6L6tb2__9rg.png" /><figcaption>Mathf.Exp()</figcaption></figure><p>I am making a rail game where you pilot a cosmic ship and shoot down enemies, and I wanted to share what I used for smooth rotation.</p><p>I want to tell how <em>Mathf.Exp()</em> works in <strong>Unity</strong>. To make my ship tilt left or right smoothly, there are many options, but I stopped at <em>Mathf.Exp()</em>.</p><p>First of all, what is <em>Mathf.Exp()</em>?</p><p>It is a mathematical exponent, an Euler number (<em>e</em>), which ≈ 2.713. The <em>Mathf.Exp()</em> method takes a power in parentheses and raises Euler’s constant to that same power.</p><pre>private void ProcessRotation()<br>    {<br>        var pitch = -controlRotationFactor * _movement.y;<br>        var roll = -controlRotationFactor * _movement.x;<br><br>        var targetRotation = Quaternion.Euler(pitch, 0f, roll);<br><br>        transform.localRotation = Quaternion.Lerp<br>        (<br>            transform.localRotation,<br>            targetRotation,<br>            1f - Mathf.Exp(-rotationSpeed * Time.deltaTime)<br>        );<br>    }</pre><p>This is the code that calculates tilts. Let’s dive into it a little.</p><p>For example, we have a powerful PC which generates high FPS, because of that <em>Time.deltaTime</em> will be a very small number. Let’s use some numbers:</p><ul><li>rotation speed = 20</li><li>Time.deltaTime = 0.02 (roughly 50 FPS)</li></ul><p><em>Mathf.Exp(-20 * 0.02) = -0.4</em></p><p>This means Euler’s number (<em>e</em>) is raised to a negative exponent. Raising <em>e</em> to a negative power produces a small value. In this case, <em>Mathf.Exp(-0.4)</em> returns a small number, which is then subtracted from <em>1f</em>.</p><p>Now, how does this work in <em>Update </em>method:</p><p>Before I tell you this, a few words about <em>Lerp </em>method. Since we use <em>Quaternion.Lerp</em>, I will talk about that one exactly. So Lerp receives 3 arguments: start unit, end unit and interpolation ratio. Imagine this interpolation ratio as a loading bar where 0 is literally 0%, and 1 is 100%</p><blockquote><strong><em>a</em></strong> - Start unit quaternion value, returned when <em>t</em> = 0.</blockquote><blockquote><strong><em>b</em></strong> - End unit quaternion value, returned when <em>t</em> = 1.</blockquote><blockquote><strong><em>t</em></strong> - Interpolation ratio. The value is clamped to the range [0, 1].</blockquote><p>In a first frame, when you press button to tilt your ship, for example, to the left, <em>Mathf.Exp</em> returns a value (<em>0.67</em> in our case) which is subtracted from <em>1f</em>, and we get <em>0.33</em> as a result. This means that in one frame, the ship is tilted by <em>33%</em> already, because first result is the highest. On the next frame, we take the same <em>33%</em> but from the remainder, here is a breakdown:</p><ol><li>1f</li><li>1f — 0.33 = 0.67</li></ol><p>Now we take 33% of 0.67, which is 0.22</p><p>3. 0.67 — 0.22 = 0.45</p><p>etc.</p><p>With every new frame we receive a smaller number, and our eye sees this like this: ship is tilted on the left and slows down the tilt speed when it reaches the target angle. In math, this is an infinite process, but in <strong>Unity</strong> numbers are eventually rounded to almost 0.</p><p>Using <em>1f — Mathf.Exp(-speedRotation * Time.deltaTime) </em>inside <em>Quaternion.Lerp</em>, we get the ideal wing pitch. The higher the player’s FPS, the smaller the steps, but the resulting smoothness and turn time will be the same whether on a low-end laptop or a powerful gaming PC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f7c680f5a53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oscillation, Mathf.PingPong, Vector3.Lerp]]></title>
            <link>https://medium.com/@ilivhsazoile.g/day-5-of-unity-game-dev-08-06-2026-c45a5a65dfd2?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c45a5a65dfd2</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 14:24:59 GMT</pubDate>
            <atom:updated>2026-07-19T09:15:34.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*HhoJhjlcH7sMzlE67HRQ9A.png" /></figure><p>When you develop a game at the beginning of your journey, you quickly notice that the environment is very static. To change that, let’s create some oscillations and move our platforms.</p><p>We will use methods like <em>Vector3.Lerp </em>and <em>Mathf.PingPong.</em></p><pre>using UnityEngine;<br><br>public class Oscillate : MonoBehaviour<br>{<br>    [SerializeField] private Vector3 movementVector;<br>    [SerializeField] private float speed;<br><br>    private Vector3 _startPosition;<br>    private Vector3 _endPosition;<br>    private float _movementFactor;<br><br>    private void Start()<br>    {<br>        _startPosition = transform.position;<br>        _endPosition = transform.position + movementVector;<br>    }<br><br>    private void Update()<br>    {<br>        _movementFactor = Mathf.PingPong(Time.time * speed, 1f);<br>        transform.position = Vector3.Lerp(_startPosition, _endPosition, _movementFactor);<br>    }<br>}</pre><p>First, we add <em>movementVector </em>and <em>speed </em>to inspector. <em>movementVector</em> receives the direction, and we tell it how far object must move. <em>speed</em> defines how fast objects move</p><p><em>_startPosition </em>simply gets the starting coordinates in <em>Start </em>with <em>transform.position</em>, and <em>_endPosition </em>is the sum of the <em>_startPosition</em> and <em>movementVector</em>.</p><p>Now <em>_movementFactor </em>is different. It defines the progress of the movement. Imagine it as a loading bar from 1% to 100%. In <em>Update </em>method, we constantly calculate it every frame using <em>Mathf.PingPong</em></p><pre>_movementFactor = Mathf.PingPong(Time.time * speed, 1f);</pre><p>So what is going on here, <em>Mathf.PingPong</em> does what you would imagine. Value goes back and forth. <em>1f</em> is our length, so in <em>Update </em>every frame <em>_movementFactor </em>is getting updated from 0.0, 0.1, 0.2… up to 1.0, when the value is 1.0, it goes back to 0.0 in the same way. And since it’s in <em>Update </em>this is an endless cycle.</p><pre>transform.position = Vector3.Lerp(_startPosition, _endPosition, _movementFactor);</pre><p>Now this is where magic happens. <em>Lerp (Linear Interpolation) </em>takes start position, end position and a “<em>loading</em>” bar. Why we did exactly <em>1f</em> in <em>PingPong </em>is perfectly described in the official documentation:</p><p><em>a</em> — <em>_startPosition</em></p><p><em>b</em> — <em>_endPosition</em></p><blockquote><em>Value used to interpolate between </em><em>a and </em><em>b. Values greater than one are clamped to </em><em>1. Values less than zero are clamped to </em><em>0.</em></blockquote><p>In short, <em>Lerp </em>is teleporting an object by a very short amount, and to our eyes, it looks like smooth movement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c45a5a65dfd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add Sounds and Particles in Unity]]></title>
            <link>https://medium.com/@ilivhsazoile.g/day-4-of-unity-game-dev-06-06-2026-db7986ababc3?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/db7986ababc3</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 14:34:38 GMT</pubDate>
            <atom:updated>2026-06-12T17:12:32.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*f5gflAsRWisrQxwODmdcGA.png" /><figcaption>sounds and particles</figcaption></figure><p>There is no game without sounds and particle effects, this is what gives life, along with other details, to our game.</p><p><strong>How to add Sounds to our project:</strong></p><p>First of all, <em>Audio Source</em> component has to be added to <em>GameObject</em>, then we create a folder where my sounds will be placed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*PV_QwcZS0ETSe13mSeKWeg.png" /><figcaption>audio folder</figcaption></figure><p>Afterwards, we declare <em>Serialized </em>variables:</p><pre>[SerializeField] private AudioClip engineThrustSfx;<br>[SerializeField] private AudioClip crashSfx;<br>[SerializeField] private AudioClip successSfx;</pre><p>And we drag and drop our sounds to newly created <em>Serialized </em>fields in Unity inspector, which were declared in <strong>Movement.cs</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*WgjNos-rdhCtTFceaxc-qg.png" /></figure><p>We write code where we do Caching, so we receive <em>Audio Source</em> reference:</p><pre>private AudioSource _audioSource;<br>    <br>private void Start()<br>    {<br>        _audioSource =  GetComponent&lt;AudioSource&gt;();<br>    }</pre><p>And we are good to go. From now on, we can easily implement our sound effects using logic. For example:</p><pre>_audioSource.PlayOneShot(audioClip)</pre><p>We call <em>PlayOneShot </em>(this method plays sound once) method on <em>_audioSource</em> and pass <em>audioClip </em>custom argument, which contains the sound. Or this example:</p><pre>private void OnCollisionEnter(Collision collision)<br>    {<br>        switch (collision.gameObject.tag)<br>        {<br>            case &quot;Friendly&quot;:<br>                break;<br>            case &quot;Finish&quot;:<br>                StartCoroutine(HandleAfterDelay(isNext: true, reload: false, audioClip: successSfx));<br>                successParticle.Play();<br>                break;<br>            default:<br>                StartCoroutine(HandleAfterDelay(isNext: false, reload: true, audioClip: crashSfx));<br>                crashParticle.Play();<br>                break;<br>        }<br>    }</pre><p>Let’s break down <em>case “Finish”</em>. When a collision happens, and <em>collision.gameObject.tag</em> is “Finish” this means in my game Player landed on the landing pad, and it’s time to load next scene, which happens with a <em>coroutine</em>. We pass a bunch of arguments and pass sound (which is declared above). Then we handle it in <strong>IEnumerator </strong>function below:</p><pre>private IEnumerator HandleSceneAfterDelay(bool isNext, bool reload, AudioClip audioClip)<br>    {<br>        // disabling Movement.cs forces to execute OnDisable method<br>        _movementScript.enabled = false;<br>        _rb.isKinematic = true;<br><br>        if (audioClip)<br>            _audioSource.PlayOneShot(audioClip);<br><br>        yield return _delay;<br>        Helpers.HandleScene(isNext, reload);<br>    }</pre><p>So if <em>audioClip </em>is not <em>null</em>, play the sound when the scene is handled.</p><p><strong>How to add Particles to our project:</strong></p><p>This process is similar to adding Sounds. Here is a screenshot of my Player Object:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*5BAe3gSmdQ9IOUfaIfrRcQ.png" /></figure><p><strong><em>Rick’s Weird Space Rocket </em></strong>was provided to me from Udemy course I follow. So here we have 5 particles. <em>Explosion </em>executes when Player hits Obstacle, <em>Success </em>when we safely land on the landing pad, and the rest are thrusters. All of those particles have this <em>Component </em>named <em>Particle System.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*0sNHK7YyxFh_1M1InNaQTA.png" /></figure><p>This is quite large system that allows you to create custom particles right in Unity.</p><p>Rest of the implementation is same as in Sounds. You declare variables, drag and drop them, and use them in your logic. They even share same methods like <em>Play()</em> or <em>Stop()</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db7986ababc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quaternion Rotation]]></title>
            <link>https://medium.com/@ilivhsazoile.g/day-3-of-unity-game-dev-02-06-2026-9ea2585b9b7f?source=rss-70d00fa60af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ea2585b9b7f</guid>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Giorgi Eliozashvili]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 17:32:06 GMT</pubDate>
            <atom:updated>2026-06-12T17:12:50.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*VfvGIFn0q_esbz_-VIdsWw.png" /></figure><p>When you work with physics in Unity you will eventually stumble upon <em>Quaternion </em>class. Official Unity documentation states:</p><blockquote>Quaternions are used to represent rotations.</blockquote><p>But behind those simple words lies a complex mathematical structure based on numbers and four-dimensional space (X, Y, Z, W).</p><p>First, let me tell you how I found out about Quaternions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*IK2GD4_PyHlU4-MwQxlxaQ.png" /></figure><p>Those orange objects are spinning. When spinners are hitting player (red ball), most of the time player goes through objects, which is not what I wanted. The reason was that spinners had no <em>Rigidbody</em>, hence no physics.</p><pre>void Update()<br>    {<br>        transform.Rotate(spinX, spinY, spinZ);<br>    }</pre><p>I had this simple <em>transform.Rotate </em>line. I found out that my issue is called <em>Tunneling. </em>Spinner was rotating too fast and since Unity is not checking collision every second, but every frame, the following bug happened:</p><ol><li>First frame: Spinner was in front of the ball</li><li>Second frame: Spinner was behind the ball</li></ol><p>To fix this issue, I was introduced to Quaternions.</p><p>Now back to Quaternions. Humans easily understand Euler Angles, that is, our beloved X, Y and Z. We can see them in Unity inspector. But Euler Angles have a bug called <strong>Gimbal Lock</strong>.</p><p>Imagine you have three rings nested inside each other like a gyroscope:</p><p>The outer ring rotates the object left and right (Y axis).</p><p>The middle ring rotates the object up and down (X axis).</p><p>The inner ring tilts the object sideways (Z axis).</p><p>They work in turns, dependent on each other. If you rotate the middle ring exactly 90 degrees, the inner ring will rotate and align itself with the outer ring.</p><p>At this point, the Z and Y axes are aligned. Now, whether you rotate the outer ring or the inner ring, the object performs exactly the same motion. However, it can no longer physically rotate in the third direction, it’s stuck. To regain the lost axis, you’ll first have to rotate the middle ring back.</p><p>For a human in real life, this isn’t a problem, but for Unity’s Euler angle math, it’s a disaster, physics breaks and loses control of one of the axes, and the object starts to jerk wildly or rotate in the wrong direction.</p><p>To resolve this issue, Quaternions were introduced. A quaternion describes a rotation not as a sequence of three separate rotations, but as a simultaneous calculation of a direction vector and the angle of rotation around it using four components: X, Y, Z, and W.</p><p>Because of a four-dimensional structure, Quaternions have three advantages:</p><ol><li><strong>No Gimbal Lock</strong> — object will rotate freely and correctly in any direction.</li><li><strong>Effective Interpolation</strong> — methods like <em>Quaternion.Slerp </em>allows calculating smooth transitions from one rotation to another.</li><li><strong>Performance</strong> — Quaternions allow the physics engine to work faster and better.</li></ol><p>To fix the issue I wrote this line of code:</p><pre>    Rigidbody rigidBody;<br><br>    void Awake()<br>    {<br>        rigidBody = GetComponent&lt;Rigidbody&gt;();<br>    }<br><br>    void FixedUpdate()<br>    {<br>        Quaternion deltaRotation = Quaternion.Euler(<br>            new Vector3(rotateX, rotateY, rotateZ) * Time.fixedDeltaTime<br>        );<br>        rigidBody.MoveRotation(rigidBody.rotation * deltaRotation);<br>    }</pre><p>Since we work with physics, we use <em>FixedUpdate </em>and <em>Time.fixedDeltaTime.</em></p><p>There we call Quaternion class and use its static method to pass three dimentional vector, and multiply it by <em>Time.fixedDeltaTime</em>. Eventually, we call <em>MoveRotation </em>on our <em>Rigidbody </em>and rotate our object.</p><p>You might ask what’s the difference between <em>Time.deltaTime</em> and <em>Time.fixedDeltaTime.</em></p><p><em>Time.deltaTime</em> — is the difference between normal frames in <em>Update</em> function. It always changes based on PC stats. Stronger the PC, less time there is between frames.</p><p><em>Time.fixedDeltaTime</em> — its fixed time between frames in <em>FixedUpdate</em> function. In Unity it is always the same, 0.02 seconds.</p><p>In a nutshell, <em>deltaTime </em>is dependent on game lag and FPS, while <em>fixedDeltaTime </em>is a stable, perfectly smooth metronome for the physics engine.</p><p>So let&#39;s just not manually intervene with Quaternions and just use given static methods of Quaternion class that are basically our translators.</p><p>To sum up, Quaternions in Unity are not a replacement for Euler angles, but rather a safe internal implementation of them. We write code and configure the inspector in degrees, but the engine converts them into Quaternions behind the scenes, so that collisions, triggers, etc., are processed smoothly, quickly, and without errors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ea2585b9b7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>