<?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: Adriel Werlich</title>
    <description>The latest articles on DEV Community by Adriel Werlich (@adrielwerlich).</description>
    <link>https://dev.to/adrielwerlich</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F139222%2F578c4dfd-3eff-4053-bd4d-8ddd948b0bec.jpeg</url>
      <title>DEV Community: Adriel Werlich</title>
      <link>https://dev.to/adrielwerlich</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adrielwerlich"/>
    <language>en</language>
    <item>
      <title>Why Use C++ Over Blueprints in Unreal Engine?</title>
      <dc:creator>Adriel Werlich</dc:creator>
      <pubDate>Sat, 21 Jun 2025 19:15:55 +0000</pubDate>
      <link>https://dev.to/adrielwerlich/why-use-c-over-blueprints-in-unreal-engine-47a3</link>
      <guid>https://dev.to/adrielwerlich/why-use-c-over-blueprints-in-unreal-engine-47a3</guid>
      <description>&lt;p&gt;Certainly! Here’s a more detailed explanation:&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Why Use C++ Over Blueprints in Unreal Engine?&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. Full Engine Access&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Blueprints are designed for ease of use and rapid iteration, but they only expose a subset of Unreal Engine’s features. With C++, you have direct access to the entire Unreal API, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low-level engine systems (rendering, physics, networking, memory management)&lt;/li&gt;
&lt;li&gt;Custom engine modules and plugins&lt;/li&gt;
&lt;li&gt;Advanced gameplay systems (AI, custom input, procedural generation)&lt;/li&gt;
&lt;li&gt;Third-party libraries and integrations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means if you need to do something not available in Blueprints, or want to deeply customize engine behavior, C++ is required.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;2. Customization and Extensibility&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;C++ allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create new classes, components, and systems not possible in Blueprints&lt;/li&gt;
&lt;li&gt;Override and extend engine functionality at any level&lt;/li&gt;
&lt;li&gt;Implement complex algorithms or data structures&lt;/li&gt;
&lt;li&gt;Write custom editor tools and workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Blueprints are great for combining existing building blocks, but C++ lets you invent new ones.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;3. Performance Considerations&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;While Unreal’s Blueprint system is highly optimized, C++ can offer performance benefits in certain scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tight loops, heavy math, or real-time calculations&lt;/li&gt;
&lt;li&gt;Systems that run every frame or on many objects (e.g., custom physics, pathfinding)&lt;/li&gt;
&lt;li&gt;Memory management and optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For most gameplay logic, the performance difference is minor. But for critical systems, C++ gives you more control over optimization.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;4. Hybrid Workflow&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Most professional Unreal projects use a hybrid approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;C++&lt;/strong&gt; for core systems, custom logic, and engine extensions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blueprints&lt;/strong&gt; for rapid prototyping, designer-driven logic, and visual scripting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C++ classes can expose variables and functions to Blueprints, allowing designers to tweak and extend gameplay without touching code.&lt;/p&gt;




&lt;h4&gt;
  
  
  &lt;strong&gt;5. Maintainability and Collaboration&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;C++ code can be easier to version control, review, and merge in large teams.&lt;/li&gt;
&lt;li&gt;Complex logic can be clearer and more maintainable in code than in large Blueprint graphs.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Summary Table&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature/Need&lt;/th&gt;
&lt;th&gt;Blueprints&lt;/th&gt;
&lt;th&gt;C++&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Rapid prototyping&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full engine access&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom engine features&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance-critical logic&lt;/td&gt;
&lt;td&gt;(some)&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Designer-friendly&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Complex algorithms&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Editor scripting/tools&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✔️&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;In short:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Blueprints for speed, accessibility, and designer iteration.&lt;/li&gt;
&lt;li&gt;Use C++ when you need full engine access, custom features, or maximum performance.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>unrealengine</category>
      <category>cppvsblueprints</category>
      <category>visualscripting</category>
      <category>bestpractices</category>
    </item>
    <item>
      <title>Chapter 2 - Converting blueprint in Cpp - BeginPlay</title>
      <dc:creator>Adriel Werlich</dc:creator>
      <pubDate>Sat, 21 Jun 2025 17:09:23 +0000</pubDate>
      <link>https://dev.to/adrielwerlich/chapter-2-converting-blueprint-in-cpp-beginplay-30l1</link>
      <guid>https://dev.to/adrielwerlich/chapter-2-converting-blueprint-in-cpp-beginplay-30l1</guid>
      <description>&lt;h1&gt;
  
  
  Chapter 2 - Converting the BeginPlay hook into C++ script
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The Event BeginPlay in blueprint/visual scritp&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r2ue3scthzpdetogf5v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r2ue3scthzpdetogf5v.png" alt="Image description" width="689" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This BeginPlay event for the Bot Player Blueprint does the following:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sequence Node&lt;/strong&gt;: Splits execution into three parallel branches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SetInputMappingContext&lt;/strong&gt;: Calls a collapsed graph to set up input mappings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;InitFireMode&lt;/strong&gt;: Calls a collapsed graph to initialize the fire mode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CreateCrosshairWidget&lt;/strong&gt;: Calls a collapsed graph to create the crosshair UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SetTag&lt;/strong&gt;: Sets a tag on the actor (likely for identification).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get All Actors of Class (BP_Enemy_Spawn)&lt;/strong&gt;: Finds all enemy spawn actors in the level.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bind Event to On All Enemies Defeated&lt;/strong&gt;: Binds a custom event (Event_ShowLevelClearedMessage) to an event dispatcher on the enemy spawner(s).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Event_ShowLevelClearedMessage&lt;/strong&gt;: Custom event that, when triggered, calls ShowLevelClearedMessage on self, passing a message to display.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;How to Convert This to C++&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Below is a C++ outline for your &lt;code&gt;BeginPlay&lt;/code&gt; logic. You’ll need to implement or stub out the collapsed graphs as C++ functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;"BotPlayer.h"&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;"Kismet/GameplayStatics.h"&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;"BP_Enemy_Spawn.h"&lt;/span&gt;&lt;span class="c1"&gt; // Replace with your actual enemy spawn class header&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;BeginPlay&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Super&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;BeginPlay&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// 1. Set up input mapping context&lt;/span&gt;
    &lt;span class="n"&gt;SetInputMappingContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// 2. Initialize fire mode&lt;/span&gt;
    &lt;span class="n"&gt;InitFireMode&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// 3. Create crosshair widget&lt;/span&gt;
    &lt;span class="n"&gt;CreateCrosshairWidget&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// 4. Set tag on this actor&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;Tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"PlayerTag"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Replace "PlayerTag" with the actual tag&lt;/span&gt;

    &lt;span class="c1"&gt;// 5. Get all enemy spawners in the level&lt;/span&gt;
    &lt;span class="n"&gt;TArray&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;AActor&lt;/span&gt;&lt;span class="o"&gt;*&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;EnemySpawners&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;UGameplayStatics&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;GetAllActorsOfClass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetWorld&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;ABP_Enemy_Spawn&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;StaticClass&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;EnemySpawners&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// 6. Bind event to OnAllEnemiesDefeated for each spawner&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AActor&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;SpawnerActor&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;EnemySpawners&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;ABP_Enemy_Spawn&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Spawner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Cast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ABP_Enemy_Spawn&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SpawnerActor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Spawner&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Assuming the spawner has a delegate like:&lt;/span&gt;
            &lt;span class="c1"&gt;// DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnAllEnemiesDefeated);&lt;/span&gt;
            &lt;span class="c1"&gt;// UPROPERTY(BlueprintAssignable) FOnAllEnemiesDefeated OnAllEnemiesDefeated;&lt;/span&gt;
            &lt;span class="n"&gt;Spawner&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;OnAllEnemiesDefeated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddDynamic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ShowLevelClearedMessage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Example stub implementations for the collapsed graphs:&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;SetInputMappingContext&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Implement input mapping setup here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;InitFireMode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Implement fire mode initialization here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CreateCrosshairWidget&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Implement crosshair widget creation here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// This function will be called when all enemies are defeated&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;ShowLevelClearedMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Implement logic to show the level cleared message&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Key Points:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;"YourTag"&lt;/code&gt; with the actual tag you want to set.&lt;/li&gt;
&lt;li&gt;Replace &lt;code&gt;ABP_Enemy_Spawn&lt;/code&gt; with your actual enemy spawner C++ class.&lt;/li&gt;
&lt;li&gt;The delegate/event system assumes your enemy spawner has a &lt;code&gt;BlueprintAssignable&lt;/code&gt; multicast delegate for "all enemies defeated."&lt;/li&gt;
&lt;li&gt;Implement the collapsed graph logic as C++ member functions.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Next is to convert each variable, function, node graph or macro into C++ code.&lt;br&gt;
For example in the blueprint we have the "CreateCrosshairWidget" that creates the target/crosshair widget in the center of the screen&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhcz3bfn92zs8c6txpc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhcz3bfn92zs8c6txpc3.png" alt="Image description" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CreateCrosshairWidget&lt;/code&gt; function does the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Gets the Player Controller&lt;/strong&gt; (index 0).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creates a User Widget&lt;/strong&gt; of a specified Widget Blueprint Class, with the player controller as the owning player.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stores&lt;/strong&gt; the created widget in a variable (&lt;code&gt;WidgetBlueprint&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adds the widget to the viewport&lt;/strong&gt; so it appears on the screen.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;C++ Conversion&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Header File (&lt;code&gt;BotPlayer.h&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// ...existing code...&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;"Blueprint/UserWidget.h"&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="n"&gt;UCLASS&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;YOURGAME_API&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;APawn&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;GENERATED_BODY&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// The crosshair widget class to use (set this in the editor)&lt;/span&gt;
    &lt;span class="n"&gt;UPROPERTY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EditAnywhere&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BlueprintReadWrite&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UI"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;TSubclassOf&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UUserWidget&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;WidgetBlueprintClass&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// The created widget instance&lt;/span&gt;
    &lt;span class="n"&gt;UPROPERTY&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;UUserWidget&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;WidgetBlueprint&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Function to create the crosshair widget&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;CreateCrosshairWidget&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  &lt;strong&gt;Source File (&lt;code&gt;BotPlayer.cpp&lt;/code&gt;)&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;"BotPlayer.h"&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;"Blueprint/UserWidget.h"&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;"Kismet/GameplayStatics.h"&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ABotPlayer&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CreateCrosshairWidget&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get the player controller&lt;/span&gt;
    &lt;span class="n"&gt;APlayerController&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;PC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;UGameplayStatics&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;GetPlayerController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetWorld&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PC&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;WidgetBlueprintClass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Create the widget&lt;/span&gt;
        &lt;span class="n"&gt;WidgetBlueprint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CreateWidget&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;UUserWidget&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;WidgetBlueprintClass&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WidgetBlueprint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Add it to the viewport&lt;/span&gt;
            &lt;span class="n"&gt;WidgetBlueprint&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;AddToViewport&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The function gets the player controller, creates the widget, stores it in a variable, and adds it to the viewport—just like the Blueprint version.
&lt;/li&gt;
&lt;li&gt;Make sure to set &lt;code&gt;WidgetBlueprintClass&lt;/code&gt; in the editor to your crosshair widget Blueprint.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>unrealengine</category>
      <category>blueprinttocpp</category>
    </item>
    <item>
      <title>How to Convert a Basic Blueprint to a C++ Class in Unreal Engine 5</title>
      <dc:creator>Adriel Werlich</dc:creator>
      <pubDate>Sat, 21 Jun 2025 15:11:09 +0000</pubDate>
      <link>https://dev.to/adrielwerlich/how-to-convert-a-basic-blueprint-to-a-c-class-in-unreal-engine-5-4if5</link>
      <guid>https://dev.to/adrielwerlich/how-to-convert-a-basic-blueprint-to-a-c-class-in-unreal-engine-5-4if5</guid>
      <description>&lt;p&gt;While it’s common to hear that C++ gives you “more control” than Blueprints, the &lt;strong&gt;main advantage of using C++ in Unreal Engine is full access to the Unreal API&lt;/strong&gt;. Many engine features, advanced systems, and low-level optimizations are only available or fully customizable in C++. Blueprints are powerful for rapid prototyping and visual scripting, but they intentionally expose only a subset of the engine’s capabilities to keep things simple and safe for designers (for more info about this look: &lt;a href="https://dev.to/adrielwerlich/why-use-c-over-blueprints-in-unreal-engine-5317-temp-slug-6257122?preview=d0ec03b331e690048c9b3c018291e604fbed34d48c38d22d094738a56539686b7ca9958606724a2032cfb544d59f912dfbccf2a23dd243b8c04d6c1b"&gt;Using cpp versus blueprint scripting&lt;/a&gt; ).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Full API Access:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
C++ lets you use every class, function, and subsystem in Unreal Engine. Some advanced features (like custom rendering, networking, or memory management) are only accessible in C++.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Custom Engine Features:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If you need to extend the engine, create custom components, or deeply modify gameplay systems, C++ is required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
While C++ can be faster in some edge cases (especially for tight loops or heavy math), Unreal’s Blueprint system is highly optimized. For most gameplay logic, the performance difference is negligible. Only in performance-critical code paths does C++ offer a clear advantage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hybrid Approach:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Many teams use C++ for core systems and expose variables/functions to Blueprints for designers to tweak and extend. This combines the strengths of both systems.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The biggest reason to use C++ is not raw speed, but &lt;strong&gt;access to the full power and flexibility of Unreal Engine&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Blueprints are ideal for most gameplay scripting, but C++ is essential for advanced or custom engine work.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This distinction helps teams choose the right tool for the job: Blueprints for speed and accessibility, C++ for depth and extensibility.&lt;/p&gt;




&lt;p&gt;Now the topic of this article is on how to convert a blueprint into a cpp class file, meaning converting visual script logic into text logic.&lt;/p&gt;




&lt;p&gt;This is the blueprint to convert. The bot player.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvz6c1w6p7n3mjlds9po0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvz6c1w6p7n3mjlds9po0.png" alt="Image description" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the Blueprint for the &lt;strong&gt;Bot Player&lt;/strong&gt; in Unreal Engine 5. Here’s a breakdown of its structure and components:&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;Components&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92p8dunfira6zsno015g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92p8dunfira6zsno015g.png" alt="Image description" width="555" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SphereCollision&lt;/strong&gt;: The root component, likely used for collision detection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BotMesh&lt;/strong&gt;: The visual mesh representing the bot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SpringArm&lt;/strong&gt;: Used to position and smooth the camera relative to the bot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ThirdPersonCamera&lt;/strong&gt;: A camera attached to the spring arm for a third-person view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FirstPersonCamera&lt;/strong&gt;: An additional camera, possibly for switching to a first-person view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FloatingPawnMovement&lt;/strong&gt;: Handles movement logic for the pawn, allowing it to move smoothly in the world.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Several custom functions are defined, such as:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Fire/SpawnBlaster&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;FireLaser&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GetEndTrace&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;GetTargetPoint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ShowLevelClearedMessage&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;IsCurrentColorNotDefault&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;And more...&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These functions likely handle the bot’s gameplay logic, including firing weapons, targeting, and displaying messages.&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;Variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Variables like &lt;code&gt;bHasRifle&lt;/code&gt; (Boolean), &lt;code&gt;RightRifleSocketName&lt;/code&gt; (Name), and various transforms and names for weapon sockets.&lt;/li&gt;
&lt;li&gt;These variables are used to manage the bot’s state, equipment, and interactions.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;Interfaces and Macros&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Blueprint may implement interfaces and macros for reusable logic and communication with other Blueprints or systems.
This blueprint does use the BPI_Damageable interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g2rd5i6yirf6858vebj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g2rd5i6yirf6858vebj.png" alt="Image description" width="490" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And also the BPI_TaggedActor&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyu0fel1c1zp2810xyhja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyu0fel1c1zp2810xyhja.png" alt="Image description" width="483" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These interfaces are used in a combat or interaction system, where:&lt;/p&gt;

&lt;p&gt;SetDamage is used when something is hit or attacked.&lt;/p&gt;

&lt;p&gt;GetTag/SetTag are used to classify identity of this actor as Player (e.g., tagging this BP_BotPlayer as having the “PlayerTag” or “EnemyTag” in case of BP_Enemy).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fagvw2i6vgdh8c4niwo5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fagvw2i6vgdh8c4niwo5i.png" alt="Image description" width="535" height="106"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
This Blueprint defines a player-controlled bot pawn with cameras for both first- and third-person views, movement logic, weapon handling, and various gameplay functions and variables. It serves as the main class for the bot player in your game.&lt;/p&gt;



&lt;ol&gt;
&lt;li&gt;Create the C++ Class
In Unreal Editor, go to File &amp;gt; New C++ Class.
Choose the appropriate parent class (e.g., APawn or ACharacter for a player, APawn or AActor for an enemy bot).
Name your class (e.g., PlayerPawn, EnemyBot).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qjh7eyty41pgymr8xjr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qjh7eyty41pgymr8xjr.png" alt="Image description" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ol&gt;
&lt;li&gt;Move Variables and Components
In your new C++ header file, declare variables and components you used in Blueprint (e.g., health, movement speed, mesh, camera).
Use UPROPERTY macros to expose them to the editor if needed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.1. Declaring and creating components (sphere collision, botmesh[staticMesh], cameras, FloatingPawnMovement)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SphereCollision: A sphere collision component, likely used for collision detection and as the root.&lt;/li&gt;
&lt;li&gt;BotMesh: A static mesh representing the bot’s visual appearance.&lt;/li&gt;
&lt;li&gt;SpringArm: A spring arm to position and smooth the camera.&lt;/li&gt;
&lt;li&gt;ThirdPersonCamera: A camera attached to the spring arm for a third-person view.&lt;/li&gt;
&lt;li&gt;FirstPersonCamera: An additional camera, possibly for first-person view.&lt;/li&gt;
&lt;li&gt;FloatingPawnMovement: Handles movement logic for the pawn.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  C++ Header File (BotPlayer.h)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "GameFramework/FloatingPawnMovement.h"
#include "Components/SphereComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "BotPlayer.generated.h"

UCLASS()
class YOURGAME_API ABotPlayer : public APawn
{
    GENERATED_BODY()

public:
    ABotPlayer();

protected:
    virtual void BeginPlay() override;

public:
    // Components
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    USphereComponent* SphereCollision;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    UStaticMeshComponent* BotMesh;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    USpringArmComponent* SpringArm;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    UCameraComponent* ThirdPersonCamera;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    UCameraComponent* FirstPersonCamera;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
    UFloatingPawnMovement* FloatingPawnMovement;
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;C++ Source File (BotPlayer.cpp)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include "BotPlayer.h"

ABotPlayer::ABotPlayer()
{
    // Set this pawn to call Tick() every frame if needed
    PrimaryActorTick.bCanEverTick = true;

    // Create components
    SphereCollision = CreateDefaultSubobject&amp;lt;USphereComponent&amp;gt;(TEXT("SphereCollision"));
    RootComponent = SphereCollision;

    BotMesh = CreateDefaultSubobject&amp;lt;UStaticMeshComponent&amp;gt;(TEXT("BotMesh"));
    BotMesh-&amp;gt;SetupAttachment(RootComponent);

    SpringArm = CreateDefaultSubobject&amp;lt;USpringArmComponent&amp;gt;(TEXT("SpringArm"));
    SpringArm-&amp;gt;SetupAttachment(RootComponent);

    ThirdPersonCamera = CreateDefaultSubobject&amp;lt;UCameraComponent&amp;gt;(TEXT("ThirdPersonCamera"));
    ThirdPersonCamera-&amp;gt;SetupAttachment(SpringArm);

    FirstPersonCamera = CreateDefaultSubobject&amp;lt;UCameraComponent&amp;gt;(TEXT("FirstPersonCamera"));
    FirstPersonCamera-&amp;gt;SetupAttachment(RootComponent);

    FloatingPawnMovement = CreateDefaultSubobject&amp;lt;UFloatingPawnMovement&amp;gt;(TEXT("FloatingPawnMovement"));
}

void ABotPlayer::BeginPlay()
{
    Super::BeginPlay();

    // Initialization logic here (if needed)
    // Example: Log that BeginPlay was called
    UE_LOG(LogTemp, Log, TEXT("BotPlayer BeginPlay!"));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Summary of Steps:&lt;/p&gt;

&lt;p&gt;All components are declared as pointers in the header file.&lt;br&gt;
All necessary Unreal Engine includes are provided.&lt;br&gt;
Components are created and attached in the constructor.&lt;br&gt;
SphereCollision is set as the root component.&lt;/p&gt;

&lt;p&gt;And here there is a call for closure to keep this not too long.&lt;br&gt;
&lt;a href="https://dev.to/adrielwerlich/chapter-2-converting-blueprint-in-cpp-beginplay-5dkm-temp-slug-8603386?preview=8e0370c3522b48020afa26b8d2ee01d7b76d1a65501116f248dbe2387728870db3b36e3fcf6ae92601bcecff83c2cf34972c8395579a1ab4447df7f6"&gt;Next chapter will bring examples of converting the BeginPlay from blueprint to a C++ script&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>unrealengine</category>
      <category>cpp</category>
      <category>blueprints</category>
      <category>visualscripting</category>
    </item>
    <item>
      <title>Creating a simple Input Action/Input Mapping Context in Unreal 5</title>
      <dc:creator>Adriel Werlich</dc:creator>
      <pubDate>Sat, 07 Jun 2025 20:54:58 +0000</pubDate>
      <link>https://dev.to/adrielwerlich/creating-a-simple-input-actioninput-mapping-context-in-unreal-5-3lln</link>
      <guid>https://dev.to/adrielwerlich/creating-a-simple-input-actioninput-mapping-context-in-unreal-5-3lln</guid>
      <description>&lt;p&gt;This can be used with a Pawn or Character derived player character, since it´s necessary to have a player controller to set the player input local subsystem to use a IMC (Input mapping context). There are 3 basic steps (1- create a input action prefixed with IA_; 2- create a input mapping context that will use the previously created IA, prefixed with IMC_; and last but not least, 3- in script, C++ or blueprint, set the IMC to be used in the player controller).&lt;/p&gt;

&lt;p&gt;1- Create a Input Action. E.g., IA_FireLaser&lt;br&gt;
While in the content browser open the context menu and in the Input section choose to create a Input Action&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdailzv23swdoo7i607s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdailzv23swdoo7i607s.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This IA is used as a boolean value (ON or OFF) to indicate if should fire weapon if user is pressing a mouse button or keyboard key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvot4wp37g3uy3j7lzgaz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvot4wp37g3uy3j7lzgaz.png" alt="Image description" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Create a Input Mapping Acton. E.g., IMC_Player&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrkd1zichflcgts9za9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrkd1zichflcgts9za9m.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This IMC binds left mouse button and Z key to this fire event.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr08aq3x7817hrndxx12c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr08aq3x7817hrndxx12c.png" alt="Image description" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- In script (C++ or blueprint) on begin play event:&lt;br&gt;
 3.1- get controller&lt;br&gt;
 3.2- cast to player controller&lt;br&gt;
 3.3- get enhanced input local player subsystem&lt;br&gt;
 3.4- add mapping context (this example is using IMC_PlayerBot in the Add Mapping Context node MappingContext field)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwpvshyqx51ijxd5rt4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwpvshyqx51ijxd5rt4x.png" alt="Image description" width="762" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally,&lt;/p&gt;

&lt;p&gt;4- in script (C++ or blueprint) create a binding&lt;br&gt;
4.1- open context menu (clicking or pressing tab)&lt;br&gt;
4.2- type the name of the input action associated with the imc previously set for this player&lt;br&gt;
4.3- link “Triggered” with a function that fire the gun/spawns the laser&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lufym17a4e6ayq8zcsz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7lufym17a4e6ayq8zcsz.png" alt="Image description" width="747" height="503"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep learning, Unreal is very broad, and there is so much to learn 👍👍👍🆒🆒🆒&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating a simple hover effect using C# script</title>
      <dc:creator>Adriel Werlich</dc:creator>
      <pubDate>Thu, 29 May 2025 06:45:51 +0000</pubDate>
      <link>https://dev.to/adrielwerlich/creating-a-simple-hover-effect-using-c-script-p76</link>
      <guid>https://dev.to/adrielwerlich/creating-a-simple-hover-effect-using-c-script-p76</guid>
      <description>&lt;h1&gt;
  
  
  Learning Unity - UI - Create button OnHover effect
&lt;/h1&gt;

&lt;p&gt;Buttons are essential UI elements, and adding hover effects makes them feel more alive — which is crucial for engaging gameplay. In this guide, you’ll learn how to implement a hover effect using a C# script in Unity. For example, you can change button color, size, create a transition animation effect, create a sound effect, animate/change text color so on... These ideas only for a hover effect, but creativity can also kick in for a OnClick effect etc.&lt;/p&gt;

&lt;p&gt;Step 1: Set Up Your Unity Project&lt;br&gt;
Open Unity and create a new 2D or 3D project&lt;/p&gt;

&lt;p&gt;In the Hierarchy panel, right-click and select UI &amp;gt; Button to create a new button&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltckpx1n6bitorieh6ob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltckpx1n6bitorieh6ob.png" alt="Create new button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 2: Customize Your Button Appearance&lt;br&gt;
Select the button in the Hierarchy&lt;/p&gt;

&lt;p&gt;In the Inspector, find the Image component&lt;/p&gt;

&lt;p&gt;Set the Source Image to your desired button appearance&lt;/p&gt;

&lt;p&gt;Adjust colors in the Color property&lt;/p&gt;

&lt;p&gt;From this screen shoot is possible to see some key points about the these buttons used to change application language using lean localization:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc00wvdo3y4w1klraiz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc00wvdo3y4w1klraiz1.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information about how to localize your game to local languages I have used this solution: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://carloswilkes.com/Documentation/LeanLocalization#Cultures" rel="noopener noreferrer"&gt;https://carloswilkes.com/Documentation/LeanLocalization#Cultures&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://assetstore.unity.com/packages/tools/localization/lean-localization-28504?aid=1101l4Jks" rel="noopener noreferrer"&gt;https://assetstore.unity.com/packages/tools/localization/lean-localization-28504?aid=1101l4Jks&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have worked previously with translation only in the context of web apps using front-end frameworks like Vue.js and React.js. I remember back in 2019 I was working in a frontend application using Vue2 and translating between 2 or 3 different languages and keeping all the text hardcoded inside each different Single-File-Component (SFC) in sync with a centralized state variable managed inside Vuex store and using computed getters to trigger reactivity everytime the user changed the language, instantaneously the UI would update and replace all text from one language to another one everything handled by javascript on the browser during runtime. Remembering that javascript is a interpreted language, dinamically typed, multi-paradigm meaning that: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JavaScript is multi-paradigm, meaning it supports object-oriented, &lt;br&gt;
 functional, and imperative programming styles — allowing developers &lt;br&gt;
 to choose the most suitable approach or mix them fluidly, depending &lt;br&gt;
 on the problem at hand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object-oriented: Classes, prototypes, inheritance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Functional: First-class functions, closures, higher-order functions, &lt;br&gt;
 immutability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Imperative: Step-by-step commands, loops, conditionals.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Create the Script
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8xotvdtzmgirahgvqne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8xotvdtzmgirahgvqne.png" alt="Create the script"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C# Script - MonoBehavior Base Class in Unity. Commonly used hooks: Start, Update, Awake, Destroy. Their names are hints for the lifecycle of objects inside the game.


using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class ButtonHoverEffect : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    private Image buttonImage;
    private Color originalColor;
    public Color hoverColor = new Color(0.8f, 0.8f, 1f); // light blue tint

    void Start()
    {
        buttonImage = GetComponent&amp;lt;Image&amp;gt;();
        if (buttonImage != null)
            originalColor = buttonImage.color;
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        if (buttonImage != null)
            buttonImage.color = hoverColor;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        if (buttonImage != null)
            buttonImage.color = originalColor;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this points you should have something looking like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqioj82ln3ubqx2nvft7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhqioj82ln3ubqx2nvft7.png" alt="Final desired result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/LpxQLTcCSdI"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Looking towards creating more about these. Just to keep up with the challenge of teaching something I want to learn.&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>csharp</category>
      <category>gamedev</category>
      <category>uidesign</category>
    </item>
  </channel>
</rss>
