<?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: Ayoub Gharbi</title>
    <description>The latest articles on DEV Community by Ayoub Gharbi (@ghayoub).</description>
    <link>https://dev.to/ghayoub</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%2F38220%2F66e8dbe8-07d1-4af9-8ae2-716a6ca901f4.jpg</url>
      <title>DEV Community: Ayoub Gharbi</title>
      <link>https://dev.to/ghayoub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ghayoub"/>
    <language>en</language>
    <item>
      <title>Youtuber Adventure!</title>
      <dc:creator>Ayoub Gharbi</dc:creator>
      <pubDate>Tue, 17 Apr 2018 18:18:17 +0000</pubDate>
      <link>https://dev.to/ghayoub/youtuber-adventure-2627</link>
      <guid>https://dev.to/ghayoub/youtuber-adventure-2627</guid>
      <description>&lt;p&gt;I was always thinking about starting my personal YouTube channel, I love teaching people why I know from my experience in programming so the time has come :&lt;/p&gt;

&lt;p&gt;I started a series called "Unity Demos" where I will make a demonstration of a features/tricks every Unity Developer can use.&lt;/p&gt;

&lt;p&gt;If you find it useful, don't forget to subscribe :)&lt;/p&gt;

&lt;p&gt;My Youtube channel link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/channel/UCYcA8F0TSz7--trnny9jM6w"&gt;https://www.youtube.com/channel/UCYcA8F0TSz7--trnny9jM6w&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to create a basic game with Unity3D!</title>
      <dc:creator>Ayoub Gharbi</dc:creator>
      <pubDate>Mon, 01 Jan 2018 14:15:10 +0000</pubDate>
      <link>https://dev.to/ghayoub/how-to-create-a-basic-game-with-unity3d-4cj4</link>
      <guid>https://dev.to/ghayoub/how-to-create-a-basic-game-with-unity3d-4cj4</guid>
      <description>&lt;p&gt;If you don’t know Unity3D, well it’s a free software that allows you to make games, it’s powerful and easy to manipulate.&lt;/p&gt;

&lt;p&gt;This article is for beginners that want to learn a little bit about game development through Unity3D, we will be using C# and Visual Studio to write code, enough talking let’s start!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8l7vN-oU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8l7vN-oU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/00.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Unity3d&lt;/p&gt;

&lt;p&gt;If it’s your first time, create an account (allows you to use Unity3d features such as Unity Collaboration or to download assets from Unity asset store..)&lt;/p&gt;

&lt;p&gt;After that, name your game(I named it “Simple Game”), check 3D , switch location of your project if you want and hit Create project!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WsTlVlgD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/01-1024x556.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WsTlVlgD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/01-1024x556.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After several seconds you will get your project opened, you can customize the default layout by drag and drop any window or you can go to the top right corner where there is a select button called Layout and switch it to the one that fits you the most, I like the Tall layout because it gives more space to the scene and game windows but you can choose whatever you like &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nMCPmMVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nMCPmMVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" alt="🙂"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first thing that we need to do now is to save/create a scene , if you noticed in the Hierarchy tab there is a Untitled Object , that’s our scene! but we need to save it by hitting File -&amp;gt; Save Scene as , give it a good name, maybe “Simple Game” &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ROERhfb2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f609.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ROERhfb2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f609.png" alt="😉"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PF1bwvCi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/02-1024x553.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PF1bwvCi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/02-1024x553.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to add the scene that we recently created to the build settings so when we export our game we will have it inside our build!&lt;/p&gt;

&lt;p&gt;Go File -&amp;gt; Build Settings ; you can drag the scene to the empty “Scenes In Build” window or you can just click add open scenes.&lt;/p&gt;

&lt;p&gt;Another way to do it is by dragging the scene into the “Scenes In Build” window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UmN1fuOm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/03-1024x556.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UmN1fuOm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/03-1024x556.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will create a ground where our character will play. In order to do that  click GameObject -&amp;gt; 3D Object -&amp;gt; Cube.&lt;/p&gt;

&lt;p&gt;You will get a nice cube inside the scene (isn’t that cool? &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nMCPmMVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nMCPmMVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" alt="🙂"&gt;&lt;/a&gt; ) now in the Inspector try to modify the Scale of that cube X : 20 , Y : 0.5 and Z : 20.&lt;/p&gt;

&lt;p&gt;Make sure that the position of the scaled cube is 0,0,0.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YcRapFsR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/04-1024x555.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YcRapFsR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2017/12/04-1024x555.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we will add our character/player , same thing GameObject -&amp;gt; 3D Object -&amp;gt; this time we will use Sphere.&lt;/p&gt;

&lt;p&gt;In the Inspector try to change the Position of the Sphere to X: 0, Y: 0.82, Z : 0.&lt;/p&gt;

&lt;p&gt;Now we need to add physics to our character so we can move it later on. To do that select the Sphere in the Hierarchy, you can see in the Inspector “Add Component” Button, click and search for Rigidbody and hit Enter!&lt;/p&gt;

&lt;p&gt;Note that we have collider component in both cube and sphere that we created , those colliders will allows physical interaction between different objects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s902Ovxq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s902Ovxq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/05.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One more thing to do before jumping to the code part , select the sphere that we created and in the inspector name it “Player”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8ujb8ntE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8ujb8ntE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/06.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the player selected in the scene, go to the inspector window and click “Add Component” this time you will time PlayerComponent in the search field you will see new script popped up as result, hit enter and then hit “Create and Add”.&lt;/p&gt;

&lt;p&gt;Now we have a script attached to our player! Double click on the script component to open it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0mLx0FOQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/07-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0mLx0FOQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/07-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is pretty much the movement script for our player. Ok let’s understand what we have wrote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public float PlayerSpeed = 20f;

private RigidBody myRigidBody = null;

private float horizontalMvt;

private float verticalMvt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This defines the player speed, with "public" keyword we are allowed to see the variable in the inspector so we can adjust the value later on.&lt;/p&gt;

&lt;p&gt;The second one is to cache the rigidbody of this gameObject so we can use it later.&lt;/p&gt;

&lt;p&gt;The two other variables are needed to store the horizontal and vertical movement of our player!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;horizontalMvt = Input.GetAxis("Horizontal");

verticalMvt = Input.GetAxis("Vertical");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those two lines allow us to get values will be in range -1 -&amp;gt; 1 (Horizontal for right/left movement, Vertical for up/down movement).&lt;/p&gt;

&lt;p&gt;To avoid input loss, we need to execute those above inside an "Update" method rather than the "FixedUpdate" one, to make sure it is only called once per frame.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myRigidBody .AddForce(new Vector3(horizontalMvt, 0, verticalMvt) \* PlayerSpeed );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line allows us to get the rigidbody that we defined earlier and add force to our player defining a new vector that contains the movement variables defined previously multiplied by the speed that we can handle from the inspector later on.&lt;/p&gt;

&lt;p&gt;Now click on the play button on the top middle of the screen , the result should be something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/00.mp4"&gt;http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/00.mp4&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s add a script that allows the camera to follow the player :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qwXYSPYP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/08-1024x852.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qwXYSPYP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/08-1024x852.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure the camera is selected and Add Component int the inspector, name it CameraFollow; Double click on the script to open it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--axMPI5sh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--axMPI5sh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/09.png" alt=""&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;public Transform Player;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First thing to do is to make sure you have a reference of the player that we wants to follow (we will reference it later from the inspector).&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Next we need to have a Vector3 that we will adjust to our need from the inspector as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private void LateUpdate() { transform.position = Player.position + Offset; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This block allows the camera to follow the player with some offset so we can visualize it on the screen otherwise they will be at the same position.&lt;/p&gt;

&lt;p&gt;Go back to Unity3d you should see something like this in the inspector:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AtsZs5w8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/10-1024x706.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AtsZs5w8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/10-1024x706.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gjA1RSqr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/11-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gjA1RSqr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/11-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try to drag and drop our Player into the Player field of the CameraFollow script.&lt;/p&gt;

&lt;p&gt;Change the offset to X: 0, Y: 5, Z: -18.&lt;/p&gt;

&lt;p&gt;Hit play and try !&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/01.mp4"&gt;http://ayoub-gharbi.org/blog/wp-content/uploads/2018/01/01.mp4&lt;/a&gt;&lt;/p&gt;

</description>
      <category>developement</category>
      <category>gamedev</category>
      <category>unity3d</category>
    </item>
    <item>
      <title>What are your programming goals for 2018? </title>
      <dc:creator>Ayoub Gharbi</dc:creator>
      <pubDate>Sat, 23 Dec 2017 17:16:23 +0000</pubDate>
      <link>https://dev.to/ghayoub/what-are-your-programming-goals-for-2018-hfj</link>
      <guid>https://dev.to/ghayoub/what-are-your-programming-goals-for-2018-hfj</guid>
      <description></description>
      <category>discuss</category>
    </item>
    <item>
      <title>Think, plan THEN code!</title>
      <dc:creator>Ayoub Gharbi</dc:creator>
      <pubDate>Mon, 06 Nov 2017 13:03:52 +0000</pubDate>
      <link>https://dev.to/ghayoub/think-plan-then-code-1nb</link>
      <guid>https://dev.to/ghayoub/think-plan-then-code-1nb</guid>
      <description>&lt;p&gt;If you have a professional experience of a few years, you might think that you’ll be able to comfortably start a project from scratch, investing in your own skills to reach the desired results.&lt;/p&gt;

&lt;p&gt;Maybe you’d think you’d even have no problems developping a project with new programming language counting on your sheer will and experience. Maybe you can but it won’t be easy. No matter how willing you are, nothing tops a good planning before initiating the developing phase of the project.&lt;/p&gt;

&lt;p&gt;I know the feeling, when you jump straight to the programming phase because you can imagine the idea clearly in your mind, but it’s not too late that problems start to appear making it hard to tell what exactly should be the right step. So it is obviously better to have a good plan from the start.&lt;/p&gt;

&lt;p&gt;Having a plan at the beginning does not mean that you need to think about the whole framework or scenario, but having a more or less clear idea at an early stage is a must. It allows you to predict the possible complications and makes you feel comfortable as you progress in the project.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
