<?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 Daniel Marabotto on Medium]]></title>
        <description><![CDATA[Stories by Daniel Marabotto on Medium]]></description>
        <link>https://medium.com/@danielmarabotto?source=rss-3037d5d41aca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UqqVY7eL9yL4tbDK1P5iQg.jpeg</url>
            <title>Stories by Daniel Marabotto on Medium</title>
            <link>https://medium.com/@danielmarabotto?source=rss-3037d5d41aca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 13:59:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielmarabotto/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[Back to Basics: Coroutines in Unity]]></title>
            <link>https://medium.com/@danielmarabotto/back-to-basics-coroutines-in-unity-0e64b58a00ce?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e64b58a00ce</guid>
            <category><![CDATA[video-game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[unity-coroutines]]></category>
            <category><![CDATA[videogames-industry]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Wed, 27 Aug 2025 21:19:58 GMT</pubDate>
            <atom:updated>2025-08-27T21:19:58.234Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*pKenCO4Yy-t5vfuTRcL10g.gif" /></figure><p>In Unity, <strong>coroutines</strong> are a way to write code that can pause execution and then continue later, without freezing the game. They are especially useful for timing events, animations, or sequences that happen over time.</p><p>Unlike the Update() method, which runs every frame, a coroutine can <strong>wait</strong> for a condition or a period of time. For example, you might want a monster to disappear for three seconds and then reappear. Doing this with just Update() would require extra variables and logic, but with a coroutine it’s simple and readable.</p><p>A coroutine is started with <strong>StartCoroutine()</strong> and uses the <strong>yield return </strong>keyword to pause. Some common yield instructions are:</p><ul><li><strong>yield return new WaitForSeconds(3f</strong>)→; waits three seconds.</li><li><strong>yield return null;</strong>→ waits until the next frame.</li><li><strong>yield return new WaitUntil(condition)</strong>→ waits until a condition becomes true.</li></ul><p>A few examples on when you might want to use coroutines are.-</p><ul><li>Make a player stronger for 5 seconds, then return to normal.</li><li>Prevent an enemy from firing continuously.</li><li>Delay between spawns.</li><li>Flash player after taking damage.</li></ul><p>In the following example, we’re going to make the monster dissapear for 3 seconds when we press the “I” key.</p><p>We’ll use a bool to block overlapping runs if I is pressed repeatedly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAc49CVOU16RFh_Sf2vt2w.png" /></figure><p>Coroutines let you write clean, step-by-step logic for timed events. They’re perfect for things like cooldowns, delayed effects, or gradual changes in gameplay. Used wisely, they make your scripts more readable and your game logic easier to manage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e64b58a00ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Back to Basics: Arrays in Unity]]></title>
            <link>https://medium.com/@danielmarabotto/back-to-basics-arrays-in-unity-b889b9abc0a3?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/b889b9abc0a3</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[video-game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 23:49:30 GMT</pubDate>
            <atom:updated>2025-08-26T23:49:30.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*wLnbD4c7umSADjTWY_WCRg.gif" /></figure><p>In programming — and especially in game development with Unity — an <strong>array</strong> is one of the simplest ways to store and organize multiple pieces of related data. You can think of an array as a row of boxes, each one holding a value, and each box has a numbered label (called an <em>index</em>) that lets you access what’s inside.</p><p>For example, if you have three different item prefabs (a sword, a shield, and a potion), you could keep them all together in one array instead of creating separate variables for each. This makes your code cleaner and easier to expand — if you add a new prefab later, you just drop it into the array instead of writing more code.</p><h3>Key Points about Arrays</h3><ol><li><strong>Fixed Size</strong> — When you create an array, you set its length (how many elements it holds). That size doesn’t change during runtime. If you need flexibility, you’d often use a “List” instead.</li><li><strong>Indexing</strong> — Arrays use numeric indexes starting at <strong>0</strong>. So the first item is <strong>[0]</strong> , the second is <strong>[1]</strong>, and so on.</li><li><strong>Grouping Related Data</strong> — Arrays shine when you want to handle groups of similar things, such as:</li></ol><ul><li>Enemy spawn points.</li><li>Sound effects for different weapons.</li><li>Player inventory slots.</li></ul><ol><li><strong>Iteration</strong> — Arrays work great with loops. A “for” loop can go through all indexes, or a “foreach” loop can touch each element without worrying about indexes.</li></ol><h3>Game Development Examples</h3><ul><li><strong>Random drops:</strong> Store several power-ups in an array, then choose one at random when an enemy is destroyed.</li><li><strong>UI slots:</strong> Keep all inventory icons in an array and update them when items change.</li><li><strong>Levels:</strong> Store scene names in an array and load them in order when the player progresses.</li></ul><h3>Why They’re Useful</h3><p>Arrays help reduce repetition, keep related data together, and make your logic more scalable. Instead of handling ten enemies with ten different variables, one array can manage them all — making your code easier to maintain and extend.</p><p>In the following example, we have an array of a few items, and we can Instantiate them in a spawn point.-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVapz_8coAfzjOsx86vYLw.png" /><figcaption>When you see [], it’s related to arrays — either defining one, or accessing one of its elements.</figcaption></figure><p>You can also add more items to the array by just dragging them into the array field in the Inspector.-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*8pLMWPjq0Rpp4jdPu-OrSQ.gif" /></figure><p>Arrays are a simple but powerful way to organize related data in Unity. By combining them with random selection and small offsets, you can create dynamic behavior like spawning different items in varied positions. Mastering arrays early will make your projects cleaner, easier to manage, and much more flexible as your game grows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b889b9abc0a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating Off-mesh Links Unity AI]]></title>
            <link>https://medium.com/@danielmarabotto/generating-off-mesh-links-unity-ai-e6534e49607a?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6534e49607a</guid>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[video-game-development]]></category>
            <category><![CDATA[off-mesh-link]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 22:13:37 GMT</pubDate>
            <atom:updated>2025-08-19T22:13:37.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*F-7fNZhh28-b6LjtlLASdw.gif" /></figure><h3>Generating Off-Mesh Links in Unity for Smarter AI Navigation</h3><p>When using Unity’s <strong>NavMesh</strong> system, AI agents normally move only across walkable areas. But what happens if there’s a gap, ledge, or obstacle? That’s where <strong>Off-Mesh Links</strong> come in. They let you define special connections between two points on your NavMesh — allowing your AI to <strong>jump, climb, or drop down</strong> between areas that aren’t directly connected.</p><h3>What Are Off-Mesh Links?</h3><p>An Off-Mesh Link is a bridge between two NavMesh surfaces. When an agent reaches one of these links, it can cross to the other side even if the NavMesh itself doesn’t connect the areas.</p><p>In the following example, out AI Drone will jump (simulated) over the spikes and lasers to get to the other “walkable” side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xNYFx6zDCur53kJcTjWzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*-hSixvDYmgbaTsRfQkTqXA.png" /></figure><p>One way to do this is to select all the floors you want to select as “Walkable”, go to the Navigation window and Bake.</p><p>Note.- if some floors that you want as NON Walkable get the Navmesh, what you can do is select them and in the Inspector, in the “Static” drop down, select “Nothing”, then Bake. Those “Floors will not have the NavMesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGAqjdPXSnURs4w9l9FfmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C6YtY1NXTjwS7TwQVgxPpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qUsFdLgLUcQJCHBqnizjw.png" /><figcaption>Add the New waypoint (“Point G”) to the List of waypoints</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptLqTwjxD0KfZo7lq7h5jg.png" /></figure><p>Once we have the “second Walkable floor” baked, we can add another Waypoint (named “Point G”)and add it to the List of waypoints (in the Inspector),then To the Floor, add an “OFF MESH LINK”.</p><p>Drag the Last Waypoint (before the jump) and the new waypoint (After the jump to the Start and End fields in the Off Mesh Link component.</p><p>By default, the NavMeshAgent (AI Drone) will move straight across a link a little bit faster than normal. For extra polish, you can override movement while the agent is on an Off-Mesh Link and animate a <strong>jump arc, climb motion, or teleport effect</strong> to make the action feel realistic.</p><p>Off-Mesh Links are a simple but powerful feature in Unity’s navigation system. By combining automatic generation with manual control where needed, you can create smarter, more believable AI movement that goes beyond flat surfaces.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6534e49607a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Finite State Machines (FSM) in Unity to Create Smart AI]]></title>
            <link>https://medium.com/@danielmarabotto/using-finite-state-machines-fsm-in-unity-to-create-smart-ai-387c5e6329bd?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/387c5e6329bd</guid>
            <category><![CDATA[finite-state-machine]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[video-games-industry]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 18:21:04 GMT</pubDate>
            <atom:updated>2025-08-19T18:21:04.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*tK9SLMbHyaomn1mcXoBHMQ.gif" /></figure><p>When building enemy or NPC behavior in Unity, one of the most effective approaches is using a <strong>Finite State Machine (FSM)</strong>. An FSM allows you to define a set of states (Idle, Patrol, Chase, Attack, Death, etc.) and manage transitions between them based on conditions, making your AI appear smart and responsive.</p><h3>Why FSM?</h3><p>Without structure, AI code can quickly become messy, full of nested “If statements”. FSMs provide a clean way to separate behavior into distinct states. Each state has its own logic, and the AI transitions when certain triggers are met—for example, an enemy might move from <em>Patrol</em> to <em>Chase</em> when the player enters its vision range.</p><p>In the following example, we have our AI drone, which will move to each waypoint (walk State), stay there for 1.5 seconds (Attack State), move to the next one and go back.</p><p>As an extra detail, when the AI drone is in a waypoint, it will also change the color of a sphere above it to simulate that the door will be unlocked once all spheres are the same color.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WA50tlsLmCXLaEdlK5fwVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMkGrboiswUuEoKP7-SmbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaMZ0gBFCKtKvknAZ2Q0GA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkDUYwaJtAEUGltqQGc0xQ.png" /></figure><p>Finite State Machines give structure and clarity to AI behavior in Unity. By separating actions into states and managing transitions, you avoid messy logic and make your enemies or NPCs feel smarter and more engaging. Whether you’re building a simple patrol system or a complex boss fight, FSMs provide a scalable foundation for responsive, believable AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=387c5e6329bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving Agents on Navmesh, Unity]]></title>
            <link>https://medium.com/@danielmarabotto/moving-agents-on-navmesh-unity-c864b9287c15?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/c864b9287c15</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[navmesh]]></category>
            <category><![CDATA[navmeshagent]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 22:16:04 GMT</pubDate>
            <atom:updated>2025-08-20T16:52:25.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*QJJLwlX4Y4LDSLzxlvbxnw.gif" /></figure><p>In Unity, the <strong>NavMesh</strong> system provides an efficient way to handle AI navigation for characters and enemies. A <strong>NavMesh</strong>(Navigation Mesh) defines the walkable surfaces in your scene, allowing agents to move intelligently while avoiding obstacles.</p><h4>Setting Up a NavMesh</h4><ol><li><strong>Bake the NavMesh</strong>:</li></ol><ul><li>Mark walkable surfaces with the “Navigation Static” flag.</li><li>Open the <strong>Navigation window</strong> (Window- AI- Navigation) and bake the mesh. This generates a mesh that agents can navigate.</li></ul><ol><li><strong>Add a NavMeshAgent</strong>:</li></ol><ul><li>Attach a NavMeshAgent component to your character or AI object.</li><li>Configure Base Offset, speed, acceleration, stopping distance, and turning radius to control movement behaviour.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9yDQXUcg-ls9QZt16e8W3g.png" /></figure><p>In your Scene, be sure to have 6 waypoints (bases with red circles in my Scene) so later we can add them to the List in the AI script and also your AI character.</p><p>With this done, let’s create a Script and call it AI and attach it to your AI character.-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1kvN3t7lrsaMKQdVQNC9g.png" /><figcaption>Be sure to add the correct library.- using UnityEngine.AI;</figcaption></figure><p>In the script above, you will need what is in side Update only if your character is not facing the way it is moving, be sure to change the angles if necessary.</p><p>Using Unity’s NavMesh and NavMeshAgents makes AI movement and pathfinding straightforward and efficient. By combining automatic navigation with proper rotation and waypoint logic, you can create lifelike, responsive characters that move smoothly through your game world. Mastering these tools opens the door to more advanced AI behaviors, from patrolling enemies to dynamic NPC interactions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c864b9287c15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Navmesh in Unity]]></title>
            <link>https://medium.com/@danielmarabotto/setting-up-navmesh-in-unity-25d73231328e?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/25d73231328e</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[navmesh]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 20:58:15 GMT</pubDate>
            <atom:updated>2025-08-17T20:58:15.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NVezcCgR0ra_ZSCgg875QQ.png" /></figure><p>A <strong>NavMesh</strong> (Navigation Mesh) in Unity is a system that allows characters and agents to navigate a 3D environment intelligently. Instead of moving in straight lines, agents can use a baked navigation map that tells them where they can walk, how to avoid obstacles, and how to find the best path to a target.</p><h3>How It Works</h3><ol><li><strong>Marking Walkable Surfaces</strong></li></ol><ul><li>Objects like floors and terrain must be marked as <em>Navigation Static</em> so Unity knows they are part of the environment.</li><li>These surfaces can then be baked into the NavMesh.</li></ul><p><strong>2. Baking the NavMesh</strong></p><ul><li>In the Navigation window, the <strong>Bake tab</strong> generates a blue overlay on walkable areas.</li><li>Settings like agent radius, height, slope, and step height define where agents can move.</li></ul><p><strong>3. Using NavMeshAgents</strong></p><ul><li>A GameObject (like a player or enemy) with a <strong>NavMeshAgent component</strong> can move across the NavMesh.</li><li>You can assign destinations in code or through AI scripts, and Unity handles the pathfinding.</li></ul><h3>Benefits</h3><ul><li>Handles pathfinding automatically.</li><li>Avoids obstacles without extra code.</li><li>Works for AI characters, NPCs, or player-controlled units.</li></ul><h3>Example Use Cases</h3><ul><li>Enemies that chase the player while avoiding walls.</li><li>NPCs patrolling a level.</li></ul><h3>How to set it up.-</h3><ul><li>Select the floors you want.</li><li>Go to Window-AI-Navigation</li><li>Next to the inspector you will see the Navigation Window</li><li>Under Object menu, check “Navigation Static” and in “Navigation Area”, choose “Walkable”</li><li>Go to the Bake menu, choose the Radious and options you want , then select “Bake”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*M7mIqlGztziqkb6G3XlS_g.png" /></figure><p>Now you can see the are in which your enemies or objects can move around, this area is mark as a blueish/teal color.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJh7QdE6CA_JpFQ8Oi2icQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25d73231328e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Click to Move System in Unity]]></title>
            <link>https://medium.com/@danielmarabotto/click-to-move-system-in-unity-b42b32d16faf?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/b42b32d16faf</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[video-game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[raycasting-in-unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 19:18:42 GMT</pubDate>
            <atom:updated>2025-08-17T19:18:42.444Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*gov0sWje2Jrm9oay9W5olw.gif" /></figure><p>A <strong>Click to Move system</strong> is a common mechanic in many top-down or isometric games where the player character moves toward the position clicked by the mouse. Unity makes this relatively easy to set up using raycasts and basic movement code.</p><ol><li><strong>Player Movement Script</strong></li></ol><ul><li>The player stores a target destination.</li><li>On each frame, the player checks if it is far enough from the destination.</li><li>If so, it calculates the direction and moves toward it at a given speed.</li></ul><p><strong>2. Pointer Script (Input Handling)</strong></p><ul><li>When the player clicks the mouse, a ray is cast from the camera to the world.</li><li>If the ray hits the floor (or a walkable surface), that hit point is sent to the player as the new target destination.</li></ul><p><strong>3. Result</strong></p><ul><li>Each click sets a new destination.</li><li>The player smoothly moves toward that point until close enough, then stops.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tN-Bwp-YLGcmKrPllTjVtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6CoFJUtL2xTaLgZCZu7hXg.png" /></figure><p>In short, a <strong>Click to Move system</strong> in Unity is a simple yet powerful mechanic: the player clicks on the world, a raycast finds the target, and the character moves smoothly toward it. It’s easy to set up and works great for top-down, RPG, or strategy games.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b42b32d16faf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Bullet Holes via Raycasting, Unity]]></title>
            <link>https://medium.com/@danielmarabotto/creating-bullet-holes-via-raycasting-unity-51c813877f0b?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/51c813877f0b</guid>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[raycasting-in-unity]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Sat, 16 Aug 2025 02:11:11 GMT</pubDate>
            <atom:updated>2025-08-16T02:11:11.472Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*n_O2dCL_FS4Opsn6PrU9ZQ.gif" /></figure><h3>Creating Bullet Holes via Raycasting in Unity</h3><p>One of the most common effects in shooters is leaving bullet holes on surfaces. In Unity, this can be achieved using <strong>raycasting</strong> to detect where a projectile would hit and then placing a bullet hole decal or sprite at that location.</p><h3>1. What is Raycasting?</h3><p>A raycast is an invisible line projected from a point in a given direction. Unity can detect if this line intersects with any colliders in the scene and return information about the hit, such as position, normal, and the object hit.</p><h3>2. How It Works for Bullet Holes</h3><p>When the player shoots, instead of instantiating a physical bullet, we can instantly raycast forward from the weapon’s muzzle or the camera to detect the hit point. If a hit is detected, we place a bullet hole object there.</p><p>We just have to write a very simple script.</p><p>Few notes.-</p><p>Since we’re using the New Input system, be sure to download the package for the Input system from the package manager, call the library and in Project Settings -under Player- set Active Input handling to “Both”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahMn0mpj_opaxlpwqemTyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rQaIDt774nOS88FIpXcAA.png" /></figure><p>With just a raycast and a prefab, you can achieve convincing bullet hole effects that enhance the realism of your game without complex physics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51c813877f0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Placing Objects Via Raycast Hits, Unity]]></title>
            <link>https://medium.com/@danielmarabotto/placing-objects-via-raycast-hits-unity-cb2bc5d56a8b?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb2bc5d56a8b</guid>
            <category><![CDATA[videogame-development]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[raycasting-in-unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 19:47:55 GMT</pubDate>
            <atom:updated>2025-08-14T01:23:55.531Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*t7v2wwYQ--gCkzbDi73M9A.gif" /><figcaption>Mouse click and random colors</figcaption></figure><p>Placing objects exactly where the player clicks in a 3D world is a common and powerful technique in Unity, often used in building systems, interaction mechanics, and level editors. One of the simplest ways to achieve this is with <strong>raycasting</strong>.</p><p>A <strong>raycast</strong> is an invisible line you project from a point in space (usually the camera) toward a direction (like the mouse cursor’s position in world space). If that ray hits a collider, Unity returns information about the hit — including the exact position, surface normal, and the object hit.</p><p><strong>Basic Workflow:</strong></p><ol><li><strong>Detect player input</strong> (e.g., left mouse click).</li><li><strong>Convert mouse position to a ray</strong> using <strong>Camera.main.ScreenPointToRay()</strong></li><li><strong>Cast the ray</strong> into the scene with <strong>Physics.Raycast.</strong></li><li><strong>Check if it hit something</strong> — if yes, get “<strong>hitInfo.point”</strong>, the exact 3D location of the hit.</li><li><strong>Instantiate</strong> the desired prefab at that point.</li><li><strong>Optional</strong>.- we’ll randomly change the color of the spheres we’ll instantiate.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZsIfingeGYse2F4Q3LLsw.png" /><figcaption>We’re using the new input system, so be sure to call the library</figcaption></figure><p>Be sure to attach this script to your camera.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb2bc5d56a8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casting Raycast from Mouse Position in Unity]]></title>
            <link>https://medium.com/@danielmarabotto/casting-raycast-from-mouse-position-in-unity-89fa49a41caf?source=rss-3037d5d41aca------2</link>
            <guid isPermaLink="false">https://medium.com/p/89fa49a41caf</guid>
            <category><![CDATA[raycasting-in-unity]]></category>
            <category><![CDATA[gamedevhq]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[videogame-development]]></category>
            <category><![CDATA[unity]]></category>
            <dc:creator><![CDATA[Daniel Marabotto]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 23:12:36 GMT</pubDate>
            <atom:updated>2025-08-12T23:12:36.232Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*M3EYtMDOedl2I_4k2fm0Xw.gif" /></figure><p>First of all, we need to know what a Raycast is.-</p><p>A R<strong>aycast</strong> is like firing an invisible, perfectly straight laser line from a point in a direction to see what it hits.</p><p>In game terms, it’s a quick way to ask: <strong>“What’s directly in front of me (and how far)?”</strong></p><h3>Why it’s useful</h3><ul><li>Click/select objects under the mouse (like pick up a map or a gun)</li><li>Hitscan weapons (<strong>INSTANT</strong> lasers/bullets)</li><li>Line-of-sight checks, AI vision</li><li>Ground checks (e.g., “am I standing on something?”)</li></ul><p>If the Raycast hits something, you get <strong>hit info</strong>: the collider hit, the exact <strong>hit</strong> <strong>point and distance</strong>. If nothing’s there, no hit.</p><p><strong>The Raycast’s job</strong> is to figure out <strong>what</strong> you clicked on, and then it’s up to your script to decide what to do next — maybe:</p><ul><li><strong>Pick up</strong> (add to inventory and remove from scene)</li><li><strong>Activate</strong> (open a door, trigger a switch)</li><li><strong>Highlight</strong> (show it’s selectable)</li><li><strong>Inspect</strong> (show extra info or zoom in)</li></ul><p>Basically, raycasting is the “detection” step, and the action (pick up, open, shoot) is whatever logic you attach to the hit result.</p><p>In this article, we’ll change the color of a cube by clicking the left mouse button, using the New Input System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpn00H47ylJdMaMhf68GnQ.png" /></figure><p>Raycasts are your game’s invisible “what’s there?” probe — a straight line you fire into the world to detect colliders and get precise hit data (point, normal — the perpendicular direction of the surface — distance). They’re perfect for mouse picking and interaction, instant-hit weapons, AI line-of-sight, ground checks, and placing effects or objects exactly on surfaces. Think of them as the detection layer; you decide the response — pick up, open, damage, highlight, or spawn something at the hit point.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89fa49a41caf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>