<?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: JoelShane</title>
    <description>The latest articles on DEV Community by JoelShane (@joelshane).</description>
    <link>https://dev.to/joelshane</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%2F1040779%2Fb8738de2-238d-4f64-a6b1-46cf3d52ba49.jpg</url>
      <title>DEV Community: JoelShane</title>
      <link>https://dev.to/joelshane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joelshane"/>
    <language>en</language>
    <item>
      <title>"Hello World" in Unity game engine</title>
      <dc:creator>JoelShane</dc:creator>
      <pubDate>Mon, 11 Dec 2023 17:53:02 +0000</pubDate>
      <link>https://dev.to/joelshane/hello-world-in-unity-game-engine-3l9o</link>
      <guid>https://dev.to/joelshane/hello-world-in-unity-game-engine-3l9o</guid>
      <description>&lt;p&gt;Unity is a powerful game development engine that allows developers to bring their ideas to life. In this tutorial, we will walk you through the process of creating a basic 3D game using Unity and C#. We will explain the steps involved and provide a detailed breakdown of the code syntax used, helping you understand what each line of code does. So, let's get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: Set Up the Project&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Download and install Unity if you haven't already.&lt;/li&gt;
&lt;li&gt;Create a new Unity project.&lt;/li&gt;
&lt;li&gt;Set the project name and location.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Create a Simple 3D Scene&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In the Unity editor, create a new empty GameObject called "Player" by right-clicking in the Hierarchy panel and selecting "Create Empty".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Attach a Rigidbody component to the "Player" GameObject by selecting it and clicking "Add Component". This allows physics-based movement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new script called "PlayerController" by right-clicking in the Project panel, selecting "Create", and choosing "C# Script".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the "PlayerController" script and let's start coding!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3: Writing the PlayerController Script&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Line 1 - 3: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System.Collections;
using System.Collections.Generic;
using UnityEngine;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These lines of code import the necessary namespaces for the script to work correctly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Line 4: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PlayerMovement : MonoBehaviour
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line of code defines a public class named "PlayerMovement" that inherits from MonoBehaviour, which is a base class provided by Unity.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Line 5 - 6: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vector3 Movement;
public float Speed;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These lines of code declare a Vector3 named "Movement" to store the player's movement direction, and a public float variable named "Speed" to control the movement speed of the player character.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Line 7 - 9: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void Start()
{

}

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

&lt;/div&gt;



&lt;p&gt;This method is automatically called once when the game starts. It currently has no code inside it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Line 10 - 14: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void Update()
{
    Movement.x = Input.GetAxis("Horizontal") * Speed * Time.deltaTime;
    Movement.y = Input.GetAxis("Vertical") * Speed * Time.deltaTime;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Update method is called once per frame. It captures the horizontal and vertical input from the player using &lt;code&gt;Input.GetAxis&lt;/code&gt;, which returns a value between -1 and 1 based on the player's input. The movement values are multiplied by the speed and the &lt;code&gt;Time.deltaTime&lt;/code&gt;, which ensures smooth movement regardless of the frame rate.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Line 15 - 18: Code Syntax Explanation&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void LateUpdate()
{
    transform.Translate(Movement, Space.Self);
}

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

&lt;/div&gt;



&lt;p&gt;The LateUpdate method is called after all Update methods have been processed. It uses the Translate function of the GameObject's transform component to move the player based on the calculated movement vector. The Space.Self argument specifies that the movement should be relative to the player's current rotation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Apply the PlayerController Script
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Drag and drop the "PlayerController" script onto the "Player" GameObject in the Unity editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Press Play to test your game!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Congratulations! You've successfully created a simple 3D game in Unity using C#. By following the step-by-step guide&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>learning</category>
      <category>unity3d</category>
    </item>
  </channel>
</rss>
