<?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 Adhambek Yashnarbekov on Medium]]></title>
        <description><![CDATA[Stories by Adhambek Yashnarbekov on Medium]]></description>
        <link>https://medium.com/@240143_54666?source=rss-b2980bba96e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p8My66NlHEmrgm7b</url>
            <title>Stories by Adhambek Yashnarbekov on Medium</title>
            <link>https://medium.com/@240143_54666?source=rss-b2980bba96e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:39:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@240143_54666/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[Game Dev challenge to become a Software Engineer in Game Development (Day 46)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-46-81c8504cda17?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/81c8504cda17</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 14:08:28 GMT</pubDate>
            <atom:updated>2026-02-01T14:08:28.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>If a pickup is in front of an enemy, the enemy will fire its weapon at the pickup to destroy it before the player can get it</h3><p>In this article, we will work on improving our game by adding a new feature. Until now, the player was able to collect pickups very easily. From now on, however, the player must fight enemies to obtain them, because enemies can fire lasers and destroy the pickups before the player reaches them. Let’s move on to the coding part so that we can learn how to implement this idea.</p><p>First, we need to see our previous Fire() method of Enemy class:</p><pre>void update(){<br>CalculateMovement();<br>Fire();<br>}<br><br>public void Fire()<br>    {<br>        if (Time.time &gt; _canFire)<br>        {<br>            _fireRate = Random.Range(3.0f, 7.0f);<br>            _canFire = Time.time + _fireRate;<br>            GameObject enemyLaser = Instantiate(_laserPrefab, transform.position - new Vector3(0, 1.5f, 0), Quaternion.identity); // vector should be a variable<br>            Laser[] lasers = enemyLaser.GetComponentsInChildren&lt;Laser&gt;();<br>            for (int i = 0; i &lt; lasers.Length; i++)<br>            {<br>                lasers[i].AssignEnenmyLaser();<br>                lasers[i].PlayLaserAudio();<br>                if(_playerBody != null)<br>                    {<br>                        if (transform.position.y &lt; _playerBody.transform.position.y <br>                        &amp;&amp; Mathf.Abs(transform.position.x - _playerBody.transform.position.x) &lt;= _minPositionXdifference)<br>                            {<br>                                Debug.Log(&quot;Backwards shooting&quot;);<br>                                lasers[i].AssignMoveUp();<br><br>                            }<br>                    }                 <br>            }<br>        }<br>    }</pre><p>This function is written only for shooting at the player. There is no power-up detection system yet. Therefore, we need to add a detector that identifies power-ups and shoots immediately. To achieve this, I decided to add a cooldown system on top of _canFire, called _canFirePowerUp, along with a faster fire rate _powerUpFireRate. This way, when the enemy detects a power-up, it can shoot lasers more rapidly. Overall, after implementing the new power-up detection system, the final code was modified as shown below:</p><pre>private float _fireRate = 3.0f;<br>private float _canFire = -1.0f;          <br>private float _powerUpFireRate = 0.8f;  <br>private float _canFirePowerUp = -1.0f;<br>void Update()<br>    {<br>        Fire(false);<br>        _powerUps = GameObject.FindGameObjectsWithTag(&quot;PowerUp&quot;);<br>        foreach(GameObject powerUp in _powerUps)<br>        {<br>            if (powerUp != null &amp;&amp; <br>                powerUp.transform.position.y &lt; transform.position.y &amp;&amp;<br>                Mathf.Abs(transform.position.x - powerUp.transform.position.x) &lt;= _minPositionXdifference )<br>            {<br>                Fire(true);<br>            }<br>        }<br>    }<br><br>    public void Fire(bool isAggressive)<br>    {<br>        bool shouldShoot = false;<br><br>        if (isAggressive)<br>        {<br>            if (Time.time &gt; _canFirePowerUp)<br>            {<br>                shouldShoot = true;<br>                _canFirePowerUp = Time.time + _powerUpFireRate; <br>        }<br>        else<br>        {<br>            if (Time.time &gt; _canFire)<br>            {<br>                shouldShoot = true;<br>                _fireRate = Random.Range(3.0f, 7.0f);<br>                _canFire = Time.time + _fireRate; <br>            }<br>        }<br><br>        if (shouldShoot)<br>        {<br>            GameObject enemyLaser = Instantiate(_laserPrefab, transform.position - new Vector3(0, 1.5f, 0), Quaternion.identity); <br>            Laser[] lasers = enemyLaser.GetComponentsInChildren&lt;Laser&gt;();<br>            <br>            for (int i = 0; i &lt; lasers.Length; i++)<br>            {<br>                lasers[i].AssignEnenmyLaser();<br>                lasers[i].PlayLaserAudio();<br>                <br>                if(_playerBody != null)<br>                {<br>                    if (transform.position.y &lt; _playerBody.transform.position.y <br>                        &amp;&amp; Mathf.Abs(transform.position.x - _playerBody.transform.position.x) &lt;= _minPositionXdifference)<br>                    {<br>                        lasers[i].AssignMoveUp();<br>                    }<br>                }                 <br>            }<br>        }<br>    }</pre><p>The logic is very simple. Basically, we collect all the power-ups into an array and check them one by one to see if any of them are in front of the enemy. If so, we activate the power-up detection system and destroy the power-up immediately.</p><pre>void Update()<br>    {<br>        Fire(false);<br><br>// READ THE CODE BELOW CAREFULLY:<br>        _powerUps = GameObject.FindGameObjectsWithTag(&quot;PowerUp&quot;);<br>        foreach(GameObject powerUp in _powerUps)<br>        {<br>            if (powerUp != null &amp;&amp; <br>                powerUp.transform.position.y &lt; transform.position.y &amp;&amp;<br>                Mathf.Abs(transform.position.x - powerUp.transform.position.x) &lt;= _minPositionXdifference )<br>            {<br>                Fire(true);<br>            }<br>        }<br>    }</pre><p>I think everything is clear now. You can also see the final result below to better understand the idea visually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*BjAU2ZosJvsiUifFl8NeCg.gif" /></figure><p>So, that’s all for today. I hope you found this article useful. If you want to learn more about game development, check out my profile, where you can find a lot of useful content about game dev. Thank you for your time and attention. Have a nice day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81c8504cda17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 45)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-45-f67a0f82a8a4?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f67a0f82a8a4</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[unity2d]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 15:31:21 GMT</pubDate>
            <atom:updated>2026-01-28T15:31:21.966Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create an enemy type that knows when it’s behind the player, and fires a weapon backwards</h3><p>So, we continue building our space shooter game. Today, we’re adding a new feature to make it more interesting — and a bit harder to play. When you’re making a game, you can’t just “finish it” and forget it. You need to keep improving it, adding new mechanics and little twists that make players want to come back.</p><p>Now here’s the idea I had: <strong>what if the rocket could shoot backwards too? </strong>That thought randomly hit me, and I immediately decided to implement it in my SpaceShooter game. (Why not?) And honestly…the result is awesome. I loved how it changed the gameplay, so I decided to write this article to show you exactly how I implemented the backwards-shooting logic, step by step, so you can use the same idea in your own projects. I think you already get the core concept — so let’s not overtalk it. Just jump straight into the code below and analyze it, and you’ll be able to implement it in your own game too:</p><pre> // Laser Class<br><br>void Update()<br>    {<br>        if (_isMovingDown == false)<br>        {<br>            MoveUp();<br>        }<br>        else<br>        {<br>            MoveDown();<br>            <br>        }<br><br>    }<br>void MoveUp()<br>    {<br>        transform.Translate(Vector3.up * _speed * Time.deltaTime);<br>        if (transform.position.y &gt;= 8.1f)<br>        {<br><br>            if (transform.parent != null)<br>            {<br>                Destroy(this.transform.parent.gameObject);<br>            }<br><br>            Destroy(this.gameObject);<br>        }<br>    }<br><br>    void MoveDown()<br>    {<br>        transform.Translate(Vector3.down * _speed * Time.deltaTime);<br>        if (transform.position.y &lt;= -6.0f)<br>        {<br>            if (transform.parent != null)<br>            {<br>                Destroy(this.transform.parent.gameObject);<br>            }<br><br>            Destroy(this.gameObject);<br>        }<br>    }<br><br>    public void AssignMoveDown()<br>        {<br>            _isMovingDown = true;<br>        }<br>    <br>    public void AssignMoveUp()<br>    {<br>         _isMovingDown = false;<br>    }</pre><p>As you can see, in the Laser class, we have four functions, namely MoveUp(), MoveDown(), AssignMoveDown(), and AssignMoveUp(), to control the movement of the shot. Basically, the MoveUp() function moves the laser up so that the player shoots upwards. Similarly, the MoveDown() function moves the laser down so that the player shoots backwards. The AssignMoveDown() and AssignMoveUp() functions help to switch between MoveUp() and MoveDown(), or vice versa.</p><p>So, we have everything ready in the Laser class to implement the backward-shooting logic. Next, we need to determine whether the enemy is behind the player or not. If so, the enemy should shoot backwards.</p><p>Let’s move to the Enemy class to complete the implementation:</p><pre>// Enemy Class<br>private GameObject _playerBody;<br>private float _fireRate = 3.0f;<br>private float _canFire = -1.0f;<br>private float _playerPositionXdifference = 2.5f;<br>[SerializeField] private GameObject _laserPrefab;<br><br><br>void Fire()<br>    {<br>        if (Time.time &gt; _canFire)<br>        {<br>            _fireRate = Random.Range(3.0f, 7.0f);<br>            _canFire = Time.time + _fireRate;<br>            GameObject enemyLaser = Instantiate(_laserPrefab, transform.position - new Vector3(0, 1.5f, 0), Quaternion.identity); // vector should be a variable<br>            _explosionSoundSource.PlayOneShot(_explosionSound);<br>            Laser[] lasers = enemyLaser.GetComponentsInChildren&lt;Laser&gt;();<br>            for (int i = 0; i &lt; lasers.Length; i++)<br>            {<br>                lasers[i].AssignMoveDown();<br>                if(_playerBody != null)<br>                    {<br>                        if (transform.position.y &lt; _playerBody.transform.position.y <br>                        &amp;&amp; Mathf.Abs(transform.position.x - _playerBody.transform.position.x) &lt;= _playerPositionXdifference)<br>                            {<br>                                Debug.Log(&quot;Backwards shooting&quot;);<br>                                lasers[i].AssignMoveUp();<br>                            }<br>                    }                 <br>            }<br>        }<br>    }</pre><p>So, the only function we need is the Fire() function to change the direction of the laser. Because in the Enemy class, we can compare the positions of the player and the enemy and let the Laser class know whether the enemy is behind the player or not. So, basically, we are collecting every instantiated laser into one array called lasers, and then assigning the AssignMoveDown() function for each, since the enemy should shoot downwards to fight the player, while the player shoots upwards. But when the enemy is behind the player, we need to assign the AssignMoveUp() function to each laser to change the direction and move upwards. Let’s look at this specific part of the code:</p><pre>if (transform.position.y &lt; _playerBody.transform.position.y &amp;&amp; Mathf.Abs(transform.position.x - _playerBody.transform.position.x) &lt;= _playerPositionXdifference)<br>                            {<br>                                Debug.Log(&quot;Backwards shooting&quot;);<br>                                lasers[i].AssignMoveUp();<br>                            }</pre><p>If you pay close attention to this part, the enemy is comparing its <strong>y</strong> and <strong>x</strong> positions with the player’s. There are two conditions needed to assign the AssignMoveUp() function to the laser:</p><ol><li>Player’s y position should be higher than enemy’s y position.</li><li>Player and Enemy should be close enough (private float _playerPositionXdifference = 2.5f; //line5) to shoot. So, difference of player’s and enemy’s x position should be no more than 2.5f</li></ol><p>If those two conditions are met, the enemy will be able to shoot upwards to kill the player from behind. You can see the final result below so that you can understand the whole idea visually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OB5o5IyzH-GnQlTX2-N3tw.gif" /></figure><p>I hope you understand everything I wrote. If you have any questions, you can ask them in the comments section, and I’ll try to answer and explain the part you didn’t understand. By the way, if you want to learn more about game development, you can check my profile, where I’ve posted a lot of articles about Unity C#.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f67a0f82a8a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 44)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-44-4cdb5d2638a1?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cdb5d2638a1</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Thu, 22 Jan 2026 18:36:13 GMT</pubDate>
            <atom:updated>2026-01-22T18:36:13.763Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create a balanced spawning system between Enemies &amp; pickups — Pickups like Health should be rare, where Ammo is frequent</h3><p>Today, I want to explain how I balanced enemy spawns and power-up spawns in my game. The game includes several types of power-ups:</p><ul><li><strong>Triple Shot PowerUp</strong> — Allows the player to shoot three bullets at once.</li><li><strong>Shield PowerUp</strong> — Protects the player from collisions with enemies, bullets, and even asteroids in space.</li><li><strong>Speed PowerUp</strong> — Temporarily increases the player’s movement speed.</li><li><strong>Ammo PowerUp</strong> — Replenishes the player’s ammunition.</li><li><strong>Medical Pack PowerUp</strong> — Restores the player’s health and grants one extra life.</li></ul><p>In my previous code, I spawned power-ups completely at random. However, this approach can make the game feel repetitive after several play sessions, because the power-ups are not balanced around their actual impact on gameplay. For example, the <strong>Medical Pack PowerUp</strong> should be rare; otherwise, the game becomes too easy. On the other hand, the <strong>Ammo PowerUp</strong> should appear more frequently, since the player cannot survive for long without sufficient ammunition. To avoid players losing interest, power-up spawn rates should be carefully designed based on their usefulness and effect on game balance, rather than being distributed randomly.</p><p>So, now I am gonna share my previous and current implementation of powerUps system so that you can compare and learn from my mistake:</p><p>Previous version:</p><pre>// SpawnManager.cs<br>[SerializeField] private GameObject[] _powerUps = new GameObject[5];<br><br>IEnumerator InstantiatePowerUpRoutine()<br>    {<br>        yield return new WaitForSeconds(3.0f);<br>        while (_keepSpawning)<br>        {<br>            Vector3 position = new Vector3(Random.Range(-9.25f, 9.25f), 7.8f, 0);<br>            int randomNumber = Random.Range(0, 5);<br>            Instantiate(_powerUps[randomNumber], position, Quaternion.identity); <br>            yield return new WaitForSeconds(Random.Range(15.0f, 20.0f));<br>        }<br><br>    }<br><br>// PowerUps.cs<br><br>[SerializeField] private int _id;<br>    private int id<br>    {<br>        get<br>        {<br>            return _id;<br>        }<br>    }<br><br>    public int GetID()<br>    {<br>        return id;<br>    <br>    }<br><br>void OnTriggerEnter2D(Collider2D other)<br>    {<br>        if (other.tag == &quot;Player&quot;)<br>        {<br>            AudioSource.PlayClipAtPoint(_powerUpsAudio, transform.position, 1.0f);<br>            Destroy(this.gameObject, 0.2f);<br>            Player player = other.transform.GetComponent&lt;Player&gt;();<br>            if (player != null)<br>            {<br>                switch (_id)<br>                {<br>                    case 0:<br>                        player.ActivateTripleShot();<br>                        break;<br>                    case 1:<br>                        player.ActivateSpeedPowerUp();<br>                        break;<br>                    case 2:<br>                        player.ComeBackShieldOriginalColor();<br>                        player.ActivateShieldPowerUp();<br>                        break;<br>                    case 3:<br>                        player.AddAmmo();<br>                        break;<br>                    case 4: <br>                        player.HealthPack();     <br>                        break;<br>                    default:<br>                        Debug.Log(&quot;Default Value&quot;);<br>                        break;<br>                }<br>            }<br>        }<br></pre><p>I added some extra logic on top of my previous code to create a more balanced power-up system. The first thing I wanted to fix was the <strong>MedicalPackPowerUp</strong> — it needed to be much rarer. I spent a while thinking about how to implement “rare” behavior without making major changes to my code. Big refactors often create unexpected bugs, and I didn’t want to spend an entire day debugging. I wanted a simple solution. Then I came up with an idea: what if I simply <strong>skipped every other Medical Pack spawn</strong>? That would instantly cut its spawn rate in half. At the same time, I wanted <strong>AmmoPowerUp</strong> to appear more often. So I added an extra Ammo option to my random selection — making Ammo the “6th” power-up. That way, when the computer picks a random number from <strong>0 to 6</strong>, Ammo has a <strong>2 out of 7 chance (~29%)</strong> to spawn, while the other power-ups only have <strong>1 out of 7 chance (~14%)</strong> each.Here’s my final solution:</p><pre>//SpawnManager.cs<br>[SerializeField] private GameObject[] _powerUps = new GameObject[6];<br>[SerializeField] private int _skipHealthPowerUp = 1;<br><br> IEnumerator InstantiatePowerUpRoutine()<br>    {<br>        yield return new WaitForSeconds(3.0f);<br>        while (_keepSpawning)<br>        {<br>            Vector3 position = new Vector3(Random.Range(-9.25f, 9.25f), 7.8f, 0);<br>            int randomNumber = Random.Range(0, 5);<br>            if (randomNumber == 4)<br>            {<br>                _skipHealthPowerUp -=1;<br>                Debug.Log(&quot;Health Pack is skipped!&quot;);<br>                if (_skipHealthPowerUp == 0)<br>                {<br>                  Instantiate(_powerUps[randomNumber], position, Quaternion.identity);<br>                  _skipHealthPowerUp = 1;  <br>                }<br>            }<br>            else<br>            {<br>               Instantiate(_powerUps[randomNumber], position, Quaternion.identity); <br>            }<br>            yield return new WaitForSeconds(Random.Range(15.0f, 20.0f));<br>        }<br><br>    }<br><br>//PowerUps.cs<br><br>[SerializeField] private int _id;<br>    public int id<br>    {<br>        get<br>        {<br>            return _id;<br>        }<br>    }<br><br>    public Vector3 position<br>    {<br>        get<br>        {<br>            return transform.position;<br>        }<br>    }<br><br>public int GetID()<br>    {<br>        return id;<br>    <br>    }<br><br>    void OnTriggerEnter2D(Collider2D other)<br>    {<br>        if (other.tag == &quot;Player&quot;)<br>        {<br>            AudioSource.PlayClipAtPoint(_powerUpsAudio, transform.position, 1.0f);<br>            Destroy(this.gameObject, 0.2f);<br>            Player player = other.transform.GetComponent&lt;Player&gt;();<br>            if (player != null)<br>            {<br>                switch (_id)<br>                {<br>                    case 0:<br>                        player.ActivateTripleShot();<br>                        break;<br>                    case 1:<br>                        player.ActivateSpeedPowerUp();<br>                        break;<br>                    case 2:<br>                        player.ComeBackShieldOriginalColor();<br>                        player.ActivateShieldPowerUp();<br>                        break;<br>                    case 3:<br>                    case 5:<br>                        player.AddAmmo();<br>                        break;<br>                    case 4: <br>                        player.HealthPack();     <br>                        break;<br>                    default:<br>                        Debug.Log(&quot;Default Value&quot;);<br>                        break;<br>                }<br>            }<br>        }<br></pre><p>Please compare those two versions and try to understand implementation of balanced-PowerUp-logic. Then look at the piece below:</p><pre>if (randomNumber == 4)<br>            {<br>                _skipHealthPowerUp -=1;<br>                Debug.Log(&quot;Health Pack is skipped!&quot;);<br>                if (_skipHealthPowerUp == 0)<br>                {<br>                  Instantiate(_powerUps[randomNumber], position, Quaternion.identity);<br>                  _skipHealthPowerUp = 1;  <br>                }</pre><p>So, basically, if Random.Range() function chooses 4, the game doesn’t instantiate the HealthPowerUp: game will skip the first powerUp and only instantiates the second one, it means HealthPowerUp (Medical Pack) has a little more 8% chance of being instantiated on the game.</p><p>When it comes to the AmmoPowerUp, I put two AmmoPowerUp in the array which means, it has almost 1/3 of instantiated powerUps will be AmmoPowerUp. As you can the code below, we have two cases: case3 and case5 calling same function —player.AddAmmo();.</p><pre>if (player != null)<br>            {<br>                switch (_id)<br>                {<br>                    case 0:<br>                        player.ActivateTripleShot();<br>                        break;<br>                    case 1:<br>                        player.ActivateSpeedPowerUp();<br>                        break;<br>                    case 2:<br>                        player.ComeBackShieldOriginalColor();<br>                        player.ActivateShieldPowerUp();<br>                        break;<br>                    case 3:<br>                    case 5:<br>                        player.AddAmmo();<br>                        break;<br>                    case 4: <br>                        player.HealthPack();     <br>                        break;<br>                    default:<br>                        Debug.Log(&quot;Default Value&quot;);<br>                        break;<br>                }</pre><p>I hope today’s logic makes sense. Honestly, I implemented this solution using the full power of my laziness. There are definitely more professional and elegant ways to achieve the same result, but this approach worked well without overcomplicating the code. If you have a better or cleaner implementation in mind, feel free to share it in the comments — I’d love to learn from it.</p><p>That’s all for today. Thank you for your time and attention. If you learned something new in the last 25 minutes, I’m more than happy — for you and for myself as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cdb5d2638a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 43)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-43-01696051200b?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/01696051200b</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[game-programming]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 16:12:50 GMT</pubDate>
            <atom:updated>2026-01-20T16:12:50.908Z</atom:updated>
            <content:encoded><![CDATA[<h3>Provide logic for some enemies to have shields — Shields allow the enemies to take 1 free hit</h3><p>During the course of the SpaceShooter game, we gave a lot of advantage to the player. Which somehow makes our game a little easier to win so that our game will eventually become boring after someone plays it for several times. So, we need to our game a little bit difficult, but manageable to play.</p><p>In this time, we try to give an advantage to the enemy. So, during the game, some enemies will be instantiated with a shield that allows them to get one free hit by the player — the enemy will die if the player shoot more than one.</p><p>Now, I am gonna be sharing the code below, please take a look.</p><pre><br>   [SerializeField] private GameObject _enemyShield;<br><br>   private bool _isEnemyShieldActive = false;<br><br>   [Range(0, 100)] [SerializeField] private int _shieldChance = 25;<br><br>  void Start(){<br>   int randomChance = Random.Range(0, 100); <br>        if (randomChance &lt;= _shieldChance) <br>        {<br>            _isEnemyShieldActive = true;<br>            _enemyShield.SetActive(true);<br>        }<br>}<br><br>private void OnTriggerEnter2D(Collider2D other)<br>    {<br>if (other.tag == &quot;Laser&quot;)<br>        {<br>            if(_isEnemyShieldActive == false)<br>                {<br>                Destroy(GetComponent&lt;Collider2D&gt;()); <br>                _explosionSoundSource.Play();<br>                Destroy(other.gameObject);<br>                _animator.SetTrigger(&quot;OnEnemyDeath&quot;);<br>                _speed = 0;<br>                Destroy(this.gameObject, 1.0f);<br>                _uiManager.UpdateScore(10); <br>                <br>                }<br>            else<br>                {<br>                 _isEnemyShieldActive = false;<br>                _enemyShield.SetActive(false);<br>                }<br>        }<br>}</pre><p>Now, I am gonna explain the every single line one by one. Firs you need to have some kind of graphical object as your enemy shield. Because, the Unity should now what to put as EnemyShield when game starts. In the second line there is a boolean value: private bool _isEnemyShieldActive = false; because we don’t want to activate the shield as game starts. We use this part: [Range(0, 100)] [SerializeField] private int _shieldChance = 25; to give 25% chance of having a shield for the enemy. As you see in the void Start() function, we have int randomChance = Random.Range(0, 100); — a random number that returns numbers between 0 and 100 as our EnemyObject instantiates. If, randomChance&lt;_shieldChance our EnemyGameObject will born with shield that enables enemy to move even after getting a shot from the player. In private void OnTriggerEnter2D(Collider2D other) function, what I basically did is very simple: when it collides with the bullet coming from the player, I am asking from enemy that if it has a shield — _isEnemyShieldActive == false. If enemy says yes, I will deactivate his shield otherwise, I will destroy the enemy within a second.</p><p>I want to share the final result with you guys. Maybe, after seeing the final result, you will understand the today’s task more deeply:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ss0eXwCki8kdMfC_8gOPaw.gif" /></figure><p>So, that’s all for today. I hope you understand everything since it it very easy but must-know logic to learn. Because, in every game, you should build some sort of shield system. So, it is good to know.</p><p>Thank you for your attention and time. If you wanna learn more about gamedev, check out my profile where I posted a lot of articles and you can learn something new from each one. But I recommend you to start from Day1 if you are new in GameDev.</p><p>See you tomorrow!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01696051200b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 42)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-42-0ec356dd4417?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ec356dd4417</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 20:05:40 GMT</pubDate>
            <atom:updated>2026-01-13T20:05:40.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create the functionality to support enemy aggression — If an enemy is close to a player, the enemy will try and “ram” it.</h3><p>Glad to see you here. As you see the topic, today we should implement enemy aggression behavior. Basically, what we are going to do is very simple but somehow sounds fancy. So, don’t panic.</p><p>To be more precise, we need to implement such a logic to our game ( Space Shooter game in my case) that wen the player comes close to the enemy, enemy first shows aggression by shaking the player and and if the distance is still close then enemy will move very fast towards the player and collide each other. I hope you understand the logic. Now, we move to the coding part.</p><p>First, we need to create a function that shakes the player:</p><pre>  private float _shakeDuration = 0.2f;<br>  private float _shakeMagnitude = 0.1f;<br><br> public void TriggerShake()<br>    {<br>        StartCoroutine(Shake());<br>    }<br><br>    IEnumerator Shake()<br>    {<br>        Vector3 originalPos = transform.localPosition;<br>        float elapsed = 0.0f;<br><br>        while (elapsed &lt; _shakeDuration)<br>        {<br>            float x = Random.Range(-1f, 1f) * _shakeMagnitude;<br>            float y = Random.Range(-1f, 1f) * _shakeMagnitude;<br><br>            transform.localPosition = new Vector3(originalPos.x + x, originalPos.y + y, originalPos.z);<br><br>            elapsed += Time.deltaTime;<br><br>            yield return null;<br>        }<br><br><br>        transform.localPosition = originalPos;<br>    }</pre><p>So, basically we shake the player — transform it ± 1 unit randomly and put it back to original position — within _shakeDuration time.</p><p>Next big part is Enemy part:</p><pre> public GameObject _playerBody;<br> private float _ramDistance = 3.0f;<br> private float _ramSpeed = 20.0f;<br> private float _cooldownTime = 2.0f;<br> private bool _isRamming = false;<br><br>void Start()<br>    {<br>        _playerBody = GameObject.FindGameObjectWithTag(&quot;Player&quot;); <br>        _player = GameObject.Find(&quot;Player&quot;).GetComponent&lt;Player&gt;();<br>        if (_player == null)<br>        {<br>            Debug.LogError(&quot;Player is NULL&quot;);<br>        }<br>  }<br> void Update()<br>{<br>    if (_player != null)<br>        {<br>             float distance = Vector3.Distance(transform.position, _playerBody.transform.position);<br>            if (distance &lt; _ramDistance &amp;&amp; !_isRamming) <br>            {<br>            StartCoroutine(RamAttack());<br>             }<br>        }<br>   <br>}<br><br>    IEnumerator RamAttack() {<br>    _isRamming = true;<br><br>    _player.TriggerShake();<br>    yield return new WaitForSeconds(0.5f);<br>    if (_playerBody != null)<br>        {<br>        Vector3 targetPos = _playerBody.transform.position;<br>        while (Vector3.Distance(transform.position, targetPos) &gt; 0.1f) {<br>        transform.position = Vector3.MoveTowards(transform.position, targetPos, _ramSpeed * Time.deltaTime);<br>        yield return null;<br>    }<br>        }<br>    <br>    yield return new WaitForSeconds(_cooldownTime);<br>    _isRamming = false;<br>}</pre><p>Please don’t panic. I know the code is very long, but it doesn’t mean it is difficult. I am gonna be explaining the every piece bit by bit, so bear with me.</p><p>In first 5 lines, we are defining the values we need for RamAttack(). We need _playerBody because we need to the exact location of rigid body and collider of player. The minimum distance that triggers the functions is _ramDistance. Cool down system _cooldownTimeis for stopping the function for a couple of seconds and triggers again as soon as the player comes close. On the Start() function, I am letting know to the game that _playerBody is a gameObject with “Player” tag. In the update function, I am triggering the RamAttack() function if the _player is exist.</p><p>In our main function IEnumerator RamAttack() I am first implementing the TriggerShake(); from player class. Next, I am getting the player’s current position as targetpos and move towards it with very high speed so that the player will have a very little chance to escape.</p><p>So, that’s all for today. Please, try to implement the same logic in your game projects. Because, there will be tons of bugs when you are implementing the logic even with written codes I gave to you. So, that’ll be practically really useful thing for your gameDev career.</p><p>Thank you for your attention. See you tomorrow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ec356dd4417" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 41)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-41-e86db14c822f?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e86db14c822f</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 19:15:21 GMT</pubDate>
            <atom:updated>2026-01-12T19:15:21.704Z</atom:updated>
            <content:encoded><![CDATA[<h3>When the ‘C’ key is pressed by the Player, Pickups quickly move to the player</h3><p>Today’s task is very easy. What you need to do just increase the value of speed of Pickups when ‘C’ key is pressed and set it back when player releases C’ key. I share the main part of the logic so that you can also implement in your projects:</p><pre> if (Input.GetKeyDown(KeyCode.C))<br>        {<br>            _speed = 5.0f;<br>        }<br><br>        if (Input.GetKeyUp(KeyCode.C))<br>        {<br>            _speed = 3.0f;<br>        }</pre><p>That’s it. As simple as I said. Thank you for your attention. See you tomorrow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e86db14c822f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 40)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-40-c997a6f4b2aa?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c997a6f4b2aa</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 18:59:42 GMT</pubDate>
            <atom:updated>2026-01-06T18:59:42.279Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create a powerup that negatively affects the player</h3><blockquote>Even though it sounds like an easy task, it took me almost a week to implement this power-up. I think I chose a slightly more difficult approach for accomplishing it. Let me first explain what I worked on throughout the week, and then we will move on to the technical aspects so that you can learn how to implement similar features in your own project as well.</blockquote><p>Imagine a space shooter game. Here is mine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ld3-zIUkAgoFR8xEGPdzMw.png" /></figure><p>As you can see in the picture, there is an asteroid flying through space. The asteroid does not come only from top to bottom, but also from right to left and left to right, which makes its movement feel more natural, like in real space. If it collides with the player, it will damage the player and reduce one third of its health. At the same time, if it collides with an enemy, it will destroy the enemy as well.</p><p>So, basically, the asteroid power-up can work both positively and negatively for the player and the enemy, which makes the game more interesting.</p><p>Now I am going to show you, step by step, how I implemented the entire logic in the game. First, we need to create an asteroid power-up with a Collider2D and Rigidbody2D in the Inspector, along with an AudioSource. Make sure that the size of the asteroid is not bigger than the size of the player or the enemy; otherwise, it will look awkward to the player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyxGBUVxG-uAzBeU4OnpIw.png" /></figure><p>Then, assign a tag to this GameObject so that we can use it to identify the asteroid and perform specific operations on it. In the next step, we need to create a new class specifically for this GameObject, because there is some logic that we need to implement by writing code.</p><p>Keep in mind that I instantiate this GameObject in the SpawnManager class, not in the NegativeAsteroid class that we are creating now. Below is the complete InstantiateNegativeAsteroidRoutine() function.</p><pre> private IEnumerator InstantiateNegativeAsteroidRoutine()<br>{<br>    while (_keepSpawning)<br>    {<br>        Vector3 topSpawn = new Vector3(Random.Range(-9.64f, 9.51f), 8.1f, 0);<br>        Vector3 rightSpawn = new Vector3(11.00f, Random.Range(-1.78f, 5.77f), 0);<br>        Vector3 leftSpawn = new Vector3(-11.00f, Random.Range(-1.78f, 5.77f), 0);<br>        <br>        Vector3[] positions = { topSpawn, rightSpawn, leftSpawn };<br><br>        Vector3[] directions = { Vector3.down, Vector3.left, Vector3.right };<br><br>        int randomIndex = Random.Range(0, 3);<br><br>        GameObject newAsteroid = Instantiate(_negativeAsteroidPowerUp, positions[randomIndex], Quaternion.identity);<br>        newAsteroid.transform.parent = _asteroidContainer.transform;<br><br>        NegativeAsteroid script = newAsteroid.GetComponent&lt;NegativeAsteroid&gt;();<br>        if (script != null)<br>        {<br>            script.SetDirection(directions[randomIndex]);<br>        }<br><br>        yield return new WaitForSeconds(Random.Range(9.0f, 12.0f));<br>    }<br>}</pre><p>If you pay attention to the code, I use a while loop to ensure that asteroids are spawned only while the player is alive. _keepSpawning is a boolean variable that becomes false when the player dies. Then, I created topSpawn, which spawns asteroids from top to bottom; rightSpawn, which spawns asteroids from right to left; and leftSpawn, which spawns asteroids from left to right. I then put these positions into an array so that I can instantiate asteroids randomly. I also created an array called directions that corresponds exactly to the spawn positions. This allows me to make the asteroids fly in the opposite direction of their instantiated positions.</p><pre>GameObject newAsteroid = Instantiate(_negativeAsteroidPowerUp, positions[randomIndex], Quaternion.identity);<br>        newAsteroid.transform.parent = _asteroidContainer.transform;</pre><p>Pay close attention to this part. When I instantiate a new _negativeAsteroidPowerUp, I place it under its parent GameObject so that my workspace stays clean, even if hundreds of the same type of GameObjects are instantiated. If you forget this step, your hierarchy will quickly become cluttered, which makes it much harder to work with multiple GameObjects in your game. Remember, if you need to instantiate several objects of the same type, you should first create a parent GameObject and then place the instantiated power-ups under it. By doing so, your project hierarchy stays organized, and your workflow looks more professional in real-world projects.</p><p>Now, we move on to the main class that we created specifically for our _negativeAsteroid GameObject. Before that, I want you to take another look at the code above, because there is something I have not covered yet.</p><pre>NegativeAsteroid script = newAsteroid.GetComponent&lt;NegativeAsteroid&gt;();<br>        if (script != null)<br>        {<br>            script.SetDirection(directions[randomIndex]);<br>        }</pre><p>But I did not forget. This part is directly associated with the class that I want to explain now. In the NegativeAsteroid class, we have a function called SetDirection(), which helps determine the direction in which the instantiated GameObject should move.</p><pre>private Vector3 _moveDirection;<br>public void SetDirection(Vector3 dir)<br>        {<br>            _moveDirection = dir;<br>            _isInitialized = true;<br>        }<br><br>    void CalculateMovement()<br>        {<br>            transform.Translate(_moveDirection * _speed * Time.deltaTime, Space.World);<br><br>            if (transform.position.y &lt; -9f || transform.position.y &gt; 10f || <br>                transform.position.x &gt; 13f || transform.position.x &lt; -13f)<br>            {<br>                Destroy(this.gameObject);<br>            }<br>        }</pre><p>As you can see, the CalculateMovement() function uses the result returned by the SetDirection() function to determine the movement direction. According to the logic inside CalculateMovement(), instantiated GameObjects are destroyed as soon as they leave the game scene. If you forget to destroy GameObjects that are already outside the scene, your game will quickly become unnecessarily heavy, and players will most likely uninstall it after the first try. So be careful with this part.</p><p>I also have AsteroidRotate() and OnTriggerEnter2D(Collider2D other) functions in this class, but I’ve already covered them in my previous articles, so there’s no need to repeat the same content here. If you want to learn more about them, please check my earlier articles, where you can find plenty of information about game development with Unity and C#.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fieLYSR7Hj6MWC1LaB9RsQ.gif" /></figure><p>That’s all for today. Thank you for your attention. If you learned something new, I’m more than happy to help you on your game development journey. You can share your ideas or questions in the comments section, and I’ll make sure to check and answer each one. See you tomorrow!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c997a6f4b2aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 39)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-39-7adde0573096?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7adde0573096</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[games]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 19:36:42 GMT</pubDate>
            <atom:updated>2025-12-23T19:36:42.029Z</atom:updated>
            <content:encoded><![CDATA[<h3>Implement wave sequencing of enemies with more enemies coming each wave</h3><p>You see the today’s task. Actually, it is very easy to implement. Basically, we need to instantiate more enemies in every X seconds. So, we use IEnumerator for both instantiating the _enemyPrefab and implementing _enemyWaweSystem. All we need to do is two coroutines and boom DONE.</p><p>Firtst we need to instantiate the enemy:</p><pre>private float _enemyInstanTime = 5.0f;<br>public void StartSpawning()<br>    {<br>        StartCoroutine(SpawnRoutine());<br>    }<br><br>    IEnumerator SpawnRoutine()<br>    {<br><br>        yield return new WaitForSeconds(3.0f);<br>        while (_keepSpawning)<br>        {<br>            Vector3 position = new Vector3(Random.Range(-9.43f, 9.43f), 8.1f, 0);<br>            GameObject newEnenmy = Instantiate(_enemyPrefab, position, Quaternion.identity);<br>            newEnenmy.transform.parent = _enemyContainer.transform;<br>            yield return new WaitForSeconds(_enemyInstanTime);<br>        }<br>    }</pre><p>All we need to do is instantiating the _enemyPrefab in every _enemyInstanTime seconds which is 5.0. The second coroutine will temporarily modify _enemyInstanTime and then revert it to its original value after a set duration.</p><pre>private float _enemyInstanTime = 5.0f;<br><br>    void Start()<br>    {<br>            StartCoroutine(_enemyWaweSystemRoutine());<br>    }<br><br>private IEnumerator _enemyWaweSystemRoutine()<br>    {<br>        yield return new WaitForSeconds(60.0f);<br>        _enemyInstanTime = 2.0f;<br>        yield return new WaitForSeconds (20.0f);<br>        _enemyInstanTime = 5.0f;<br><br>    }</pre><p>As you can see in every 60 seconds, function instantiates the _enemyPrefab more faster (one prefab in every 2.0 seconds instead of 5.0) for 20 seconds. After 20 seconds, we set the _enemyInstanTime back to its original value.</p><p>You can see the difference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cxlOKWNg6aZWlVEPiqh4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8y8XKx5Vr88jdvv_Bz45w.png" /><figcaption>Picture1: when _enemyWaweSystem <strong>is not active</strong>; Picture2: when when _enemyWaweSystem <strong>is active</strong></figcaption></figure><p>That’s all for today. Thank you for your attention and time. I hope you understand the main concept and be able to implement simillar logic in your game. If you wanna learn more about gameDev, you can check out my profile where you can find detailed explanation for every topic that you wanna learn.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7adde0573096" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 38)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-38-fc220a0af50b?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc220a0af50b</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[sidewalk]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Tue, 23 Dec 2025 17:31:48 GMT</pubDate>
            <atom:updated>2025-12-23T17:31:48.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enable the Enemies to move in a new way, either from side to side, circling, or coming into the play field at an angle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hrKzCD9Nj1gdudtxrA3j6A.gif" /></figure><p>In this article, we are gonna be talking about how to add sidewalk feature to our game. Sounds like very simple, but it took me so much time to implement. So please, pay close attention so that it will take you less time and effort. <br>Let’s look at the script:</p><pre>private IEnumerator SideWalkRoutine()<br>{<br>    while (true)<br>    {  <br>        float direction = _moveRight ? 1f : -1f;<br>        transform.Translate(Vector3.right * direction * _sideWalkSpeed * Time.deltaTime);<br> <br>        if (Random.value &lt; 0.01f) <br>        {<br>            float downAmount = Random.Range(0.1f, 0.5f);<br>            transform.Translate(Vector3.down * downAmount);<br>        }<br>        // Randomly decide to change direction<br>        if ((transform.position.x &gt;= 5f &amp;&amp; _moveRight) || (transform.position.x &lt;= -5f &amp;&amp; !_moveRight) || Random.value &lt; 0.005f)<br>        {<br>            _moveRight = !_moveRight;<br>        }<br>        yield return null;<br>    }<br>}</pre><p>The script creates a <strong>horizontal zigzag or swaying behavior</strong> that runs independently of the enemy’s vertical descent.</p><p>It is implemented using a <strong>Coroutine</strong> called SideWalkRoutine(). Unlike the standard Update() method which handles the downward movement, this coroutine manages the left-to-right logic in the background.</p><p>Here is the breakdown of how it works:</p><h4>1. The Coroutine Loop</h4><p>The logic is wrapped in a while (true) loop. Because it contains yield return null, it executes its code once per frame, then &quot;pauses&quot; and hands control back to Unity until the next frame. This allows it to run continuously for the lifetime of the enemy.</p><p>The script uses the boolean _moveRight as a switch. If true, the direction is 1 (Right); if false, it is -1 (Left). It then applies this to the transform.Translate to move the enemy horizontally.</p><h3>3. Boundary &amp; Random Switching</h3><p>The script decides when to turn around based on three conditions:</p><ul><li><strong>The Right Boundary:</strong> If the X position is greater than or equal to 5f.</li><li><strong>The Left Boundary:</strong> If the X position is less than or equal to -5f.</li><li><strong>Random Chance:</strong> There is a 0.5% chance every frame (Random.value &lt; 0.005f) that the enemy will randomly change direction even if it hasn&#39;t hit a wall yet. This makes the movement feel less robotic and more unpredictable.</li></ul><p>The “sidewalk” routine also includes a 1% chance per frame to make the enemy suddenly “teleport” or jerk downward by a small random amount. This adds a twitchy, aggressive feel to the movement.</p><pre>if (Random.value &lt; 0.01f) <br>{<br>    float downAmount = Random.Range(0.1f, 0.5f);<br>    transform.Translate(Vector3.down * downAmount);<br>}</pre><p>That’s all for today. I hope you’ve learnt something new today. If so, I am really happy because if I understand the topic well, then I can explain it such way that reader can understand easily. If you wanna learn more about my gameDev, please check out my profile where I posted a lot of articles about gameDev.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc220a0af50b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Game Dev challenge to become a Software Engineer in Game Development (Day 37)]]></title>
            <link>https://medium.com/@240143_54666/game-dev-challenge-to-become-a-software-engineer-in-game-development-day-37-c98d95478ced?source=rss-b2980bba96e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c98d95478ced</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[multi-directional-shot]]></category>
            <dc:creator><![CDATA[Adhambek Yashnarbekov]]></dc:creator>
            <pubDate>Wed, 17 Dec 2025 08:18:28 GMT</pubDate>
            <atom:updated>2025-12-17T08:18:28.453Z</atom:updated>
            <content:encoded><![CDATA[<h3>Multi Direction Shot</h3><p>In this article, we are gonna be learning how to implement multi directional shot to our player. What I mean by multi directional is that if you press some of the keys in your keyboard, your player will rotate and instantiate the laser.</p><p>The thing that we need to pay close attention is that player has two position: local — objects local coordinate system and global — global coordinate system of the scene. Because when we rotate the player, we also need to rotate the laser as well.</p><pre>public void MultiDirectionShoot()<br>    {<br>        if (Input.GetKey(KeyCode.LeftShift))<br>        {<br>            transform.Rotate(Vector3.forward * Time.deltaTime * rotationSpeed);<br>        }  <br><br>        else if (Input.GetKey(KeyCode.RightShift))<br>        {<br>            transform.Rotate(Vector3.forward* Time.deltaTime * -rotationSpeed);<br>        }<br>    }</pre><p>This is my function to implement rotation for the player. After applying this function to the game and still instantiate the laser (shot) with transform.position, we will end up with a bug. Because, even though our player rotates, it will shot the laser to straight up (same location when it was 90 degrees). This is the exact mistake I did while I was doing the project:</p><pre>Instantiate(_laserPrefab, tranform.position, Quaternion.identity);</pre><p>To avoid this bug, we need adjust local value to the global value using transform.TransformPoint() built-in function:</p><pre>void FireLaser()<br>    {<br>        Vector3 spawnPosition = transform.TransformPoint(new Vector3(0f, 1.6f, 0f));<br>        if (_laserCount &gt; 0)<br>        {<br>                GameObject newLaserShot = Instantiate(_laserPrefab, spawnPosition, Quaternion.identity);<br>                newLaserShot.transform.rotation = transform.rotation;<br>                _laserCount -= 1;<br>                _audioSource.Play();<br>        }<br>    }</pre><p>You see, first I adjusted the player’s local position to global position and attached the value to Vector3 spawnPosition, then I instantiated the _laserPrefab to spawnPosition. Now, player’s shot will be directed to same location as player’s location. Final result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*rFf2jqQYVNZp2ReSdt3NPw.gif" /></figure><p>That’s all for today. Thank you for your time and attention. I hope you find it useful. If so, I am really happy and excited. By the way, if you check my profile you can find a lot of interesting stuff about game dev. I strongly recommend to read those articles if you are beginner in game dev, because I wrote detailed explanation for every topic and you may learn from my own experience and mistakes.</p><p>Thanks once again. See you in Day 38.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c98d95478ced" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>