<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Karthick Gunasekaran </title>
    <description>The latest articles on DEV Community by Karthick Gunasekaran  (@karthickgunasekaran).</description>
    <link>https://dev.to/karthickgunasekaran</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Karthick Gunasekaran </title>
      <link>https://dev.to/karthickgunasekaran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karthickgunasekaran"/>
    <language>en</language>
    <item>
      <title>Building a Reusable Interaction Framework in Unity — Day 01</title>
      <dc:creator>Karthick Gunasekaran </dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:51:07 +0000</pubDate>
      <link>https://dev.to/karthickgunasekaran/building-a-reusable-interaction-framework-in-unity-day-01-3gfl</link>
      <guid>https://dev.to/karthickgunasekaran/building-a-reusable-interaction-framework-in-unity-day-01-3gfl</guid>
      <description>&lt;p&gt;Building a Reusable Interaction Framework in Unity — Day 01&lt;/p&gt;

&lt;p&gt;By Karthick Gunasekaran&lt;/p&gt;

&lt;p&gt;I'm a Unity developer exploring gameplay programming and technical art. I want to use this space to document the systems I build, the engineering decisions behind them, the problems I encounter, and the things I learn along the way.&lt;/p&gt;

&lt;p&gt;For my first development series, I'm working on a reusable Interaction Framework in Unity.&lt;/p&gt;

&lt;p&gt;Rather than creating individual interaction scripts for every object, the goal is to build a modular foundation that can support different types of interactable objects.&lt;/p&gt;

&lt;p&gt;Why build an interaction framework?&lt;/p&gt;

&lt;p&gt;Interactions are among the fundamental systems in most games.&lt;/p&gt;

&lt;p&gt;Opening a door, picking up an object, activating a terminal or interacting with an environmental element may appear simple individually. However, as a project grows, managing these behaviours independently can become difficult.&lt;/p&gt;

&lt;p&gt;I wanted to explore an architecture where detection, interaction behaviour and visual feedback have separate responsibilities.&lt;/p&gt;

&lt;p&gt;Initial architecture&lt;/p&gt;

&lt;p&gt;The first version is built around a few core components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CameraDataCollector: Detects interactable objects using a camera-centred raycast.&lt;/li&gt;
&lt;li&gt;IInteractable: Defines a common contract for different interactable objects.&lt;/li&gt;
&lt;li&gt;PlayerInput: Handles the player's interaction request.&lt;/li&gt;
&lt;li&gt;InteractionHandler: Connects the input request with the currently detected interactable.&lt;/li&gt;
&lt;li&gt;InteractableFeedback: Handles optional visual feedback when an object becomes the current target.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important decision was to use interfaces instead of depending on a specific interactable class.&lt;/p&gt;

&lt;p&gt;This allows different objects to implement their own interaction behaviour while the framework communicates through a common contract.&lt;/p&gt;

&lt;p&gt;Camera detection and target transitions&lt;/p&gt;

&lt;p&gt;The first implementation focuses on identifying what the player is looking at.&lt;/p&gt;

&lt;p&gt;I wanted the detection system to recognise three important transitions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Entering an interactable's detection area.&lt;/li&gt;
&lt;li&gt;Switching from one interactable to another.&lt;/li&gt;
&lt;li&gt;Leaving an interactable and looking somewhere else.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of broadcasting an event every frame, the system compares the current target with the previous target and publishes an event only when a change occurs.&lt;/p&gt;

&lt;p&gt;This became the foundation for connecting visual feedback without tightly coupling it to the detection logic.&lt;/p&gt;

&lt;p&gt;Supporting different GameObject hierarchies&lt;/p&gt;

&lt;p&gt;I tested two arrangements:&lt;/p&gt;

&lt;p&gt;Test A: The interactable component, feedback component and collider are on the same GameObject.&lt;/p&gt;

&lt;p&gt;Test B: The interactable and feedback components are on the parent, while the collider and renderer are on a child.&lt;/p&gt;

&lt;p&gt;Supporting both arrangements is important because an interactable's logical behaviour does not necessarily need to live on the same GameObject as its visual representation.&lt;/p&gt;

&lt;p&gt;Debugging the material feedback system&lt;/p&gt;

&lt;p&gt;One of the interesting challenges was getting runtime material swapping to work correctly.&lt;/p&gt;

&lt;p&gt;Initially, I used a fixed-size material array with 15 elements. This caused problems because the array size did not necessarily correspond to the renderer's actual material slots.&lt;/p&gt;

&lt;p&gt;I changed the implementation to create the material arrays dynamically based on the renderer's existing material count.&lt;/p&gt;

&lt;p&gt;That resolved the visual feedback issue, and the highlight material is now being applied and restored correctly.&lt;/p&gt;

&lt;p&gt;A small debugging exercise, but a useful reminder to avoid arbitrary assumptions when working with Unity's renderer and material APIs.&lt;/p&gt;

&lt;p&gt;Visual development&lt;/p&gt;

&lt;p&gt;Alongside the programming work, I used ProBuilder to improve the scene's look and feel.&lt;/p&gt;

&lt;p&gt;This helped me move beyond testing the framework with plain primitive objects and start giving the prototype a more intentional visual presentation.&lt;/p&gt;

&lt;p&gt;Current progress&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Camera-based target detection implemented and tested.&lt;/li&gt;
&lt;li&gt;Interface-based interactable identification.&lt;/li&gt;
&lt;li&gt;Target entry, switching, exit and reacquisition working.&lt;/li&gt;
&lt;li&gt;Event-driven visual feedback implemented.&lt;/li&gt;
&lt;li&gt;Runtime material swapping and restoration working.&lt;/li&gt;
&lt;li&gt;Tested two different GameObject hierarchy arrangements.&lt;/li&gt;
&lt;li&gt;Initial scene visual improvements using ProBuilder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What's next?&lt;/p&gt;

&lt;p&gt;The next goal is to complete the first version of the framework by connecting player input and interaction execution.&lt;/p&gt;

&lt;p&gt;After that, I'll test different interactable implementations and continue improving the framework's flexibility.&lt;/p&gt;

&lt;p&gt;This is just the beginning of the project.&lt;/p&gt;

&lt;p&gt;I'll document the progress, technical decisions and lessons learned as the framework evolves.&lt;/p&gt;




&lt;p&gt;Project: Unity Interaction Framework&lt;br&gt;
Series: Gameplay Programming — Project 01&lt;br&gt;
Status: In Development&lt;/p&gt;

&lt;h1&gt;
  
  
  Unity #GameDevelopment #GameplayProgramming #CSharp #Unity3D #ProBuilder #SoftwareArchitecture
&lt;/h1&gt;

</description>
      <category>gamedev</category>
      <category>gameplayprogamming</category>
      <category>newbie</category>
      <category>unity3d</category>
    </item>
  </channel>
</rss>
