<?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 Mustafa Mert Aladağ on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Mert Aladağ on Medium]]></description>
        <link>https://medium.com/@mstfmrt07?source=rss-eb6c84c3f69b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ku1GlPI_YGumjuUNt2bzmw.jpeg</url>
            <title>Stories by Mustafa Mert Aladağ on Medium</title>
            <link>https://medium.com/@mstfmrt07?source=rss-eb6c84c3f69b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:29:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mstfmrt07/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[The Stanley Parable’s Approach to Free Will Problem]]></title>
            <link>https://mstfmrt07.medium.com/the-stanley-parables-approach-to-the-free-will-problem-32bcd89018fd?source=rss-eb6c84c3f69b------2</link>
            <guid isPermaLink="false">https://medium.com/p/32bcd89018fd</guid>
            <category><![CDATA[game-philosophy]]></category>
            <category><![CDATA[choices]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[free-will]]></category>
            <category><![CDATA[the-stanley-parable]]></category>
            <dc:creator><![CDATA[Mustafa Mert Aladağ]]></dc:creator>
            <pubDate>Sun, 01 May 2022 23:04:42 GMT</pubDate>
            <atom:updated>2022-10-10T20:41:05.113Z</atom:updated>
            <content:encoded><![CDATA[<p>Are we really free in our decisions, or is this just a fairytale that has been told us from beginning of the humankind? Do humans really want to decide their own fate, or do we really not have a desire to taste freedom at all? These are the questions that philosophers have been looking for an answer for centuries. Nevertheless, they are very-well handled in this particular game: The Stanley Parable. In this article, we will have a look at what is the game about and analyze the way that it approaches to free will problem. This article is free of spoilers, you may read it with peace in mind :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*4J9y2uCNlCIcH9UMUW2c6A.png" /></figure><blockquote>“You will play as Stanley, and you will not play as Stanley. You will follow a story, you will not follow a story. You will have a choice, you will have no choice. The game will end, the game will never end.”</blockquote><blockquote><strong>-from the Steam page of The Stanley Parable</strong></blockquote><p>First of all, The Stanley Parable is a first person, interactive discovery game developed and published by Galactic Cafe. In the game, we control a silent protagonist character called Stanley, who is an employee (number 427) in a big office. He is responsible for constantly pushing a certain button for a certain duration. And which button to push? How long to push? These are all reflected through a monitor on his desk. Such an easy and satisfying job, isn’t it? And of course, our hero fulfills this very task without questioning and any doubts, contentedly. One day, the screen goes blank and stops giving orders, which has never happened before. Stanley, stupefiedly, begins the explore the workplace, discovers that the office is completely abandoned. At that moment; his story begins. A narrator accompanies him during his journey, telling him to perform the given instructions in order to find out what happened to his co-workers. To illustrate, during your adventure, when you have two doors in front of you, he says “Stanley went left.” But here is the thing: you are not obliged to go left. Of course, as a player, you have the option the decide which path you want to go with, oh wait… Do you?</p><p>Synopsis of the game is simple: the narrator claims directing you to a path that would lead Stanley to freedom, yet you still have the chance to shape your own story as you wish, which apparently won’t make the narrator happy. Each different path you choose, sets sails to a wide range of different endings. In some cases, the narrator, breaking the <a href="https://en.wikipedia.org/wiki/Fourth_wall">fourth wall</a>, reacts to your decisions. Whenever you choose an “inconvenient” path, he gets upset and tries to convince you to follow the exact direction he wants, claiming that obedience is something good and his aim is not more than helping you with the problem you are facing. After you disobey him for a couple of times, he gets completely mad and blocks your way (which makes you stuck in the game) in order to follow the “proper” path.</p><p>The most important question Stanley raises is “Are we free in our choices?” Well, you can follow the path which narrator claims will take you to freedom, but do you really wish to sacrifice your free will, in order to achieve this “promised” freedom? Or isn’t there actually a free will to sacrifice at all? Is every decision you made already predetermined by someone else? Have you ever thought that even if you completely disobey the narrator, aren’t these decisions also -inversely- correlated on the narrator’s instructions?</p><p>To conclude, after asking too many questions, we realize that Stanley actually is used to receiving orders, and even worse, content to be slave. Narrator tells that we are making Stanley sad by defying him, as normal Stanley would follow his orders and wouldn’t break the flow of his story. Stanley didn’t have a desire to be free, actually, why should he? Why do we have to take a rather gruesome responsibility as making choices when, like Stanley, it is easy to receive orders from a computer? As Jean-Paul Sartre states, becoming aware of one’s own free will causes anxiety. Think about it, we all get confused and spend a lot of time staring at the market shelves when we want to buy some simple stuff but there are a lot of different types, brands and price tags present there, don’t we? Wouldn’t it be easier if there were just only one type of pasta, we bought it and left the store in a short period of time, having more time on more “important” stuff than deciding which pasta to buy? Sometimes becoming a Stanley is not a bad thing, is it? Well, did you decide whether you will be a Stanley or not, or are you <strong>too Stanley</strong> to decide it?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32bcd89018fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making a Bloxorz Game in Unity (Part I: Roll the Cube)]]></title>
            <link>https://mstfmrt07.medium.com/making-a-bloxorz-game-in-unity-part-i-roll-the-cube-67113d48415a?source=rss-eb6c84c3f69b------2</link>
            <guid isPermaLink="false">https://medium.com/p/67113d48415a</guid>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[bloxorz]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[roll]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Mustafa Mert Aladağ]]></dc:creator>
            <pubDate>Sun, 20 Jun 2021 18:11:05 GMT</pubDate>
            <atom:updated>2021-06-20T18:11:05.775Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article and following, we will develop a Bloxorz game by using Unity Game Engine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WzwDHMnHYVTVUW7U29koSw.gif" /></figure><p>To start with, create an empty 3D project in Unity Hub and create a player object by adding a rigidbody and a box collider component and a graphics (preferably a cube) as a child. In our example, the collider and rigidbody settings will be like below. We want our rigidbody be affected by only Y axis, so let’s modify the rigidbody constraints accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-WGA5tfCHL04RypCptRoQ.png" /><figcaption>A simple starting scene.</figcaption></figure><p>For the input, we will use the Swipe Detector script that we have created in my previous article. Click <a href="https://mstfmrt07.medium.com/swipe-detection-in-unity-5e8dc7a6fe17">here</a> if you haven’t read it yet. Now, we want our player to roll to a direction whenever a swipe is detected. To reach this, let’s improve our InputManager script by adding some extra lines to it.</p><p>Firstly, let’s create an event which will be triggered when a swipe is detected (Don’t forget to import the ‘System’ library which Action class belongs to.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b09ae01da89ef62e598c6244885dbb02/href">https://medium.com/media/b09ae01da89ef62e598c6244885dbb02/href</a></iframe><p>After that, let’s trigger our event in case a swipe is detected. (Simply add the 6th and 7th lines into OnEndDrag method.)</p><p>NOTE: As I stated in the previous article, since Pointer events are triggered on the UI objects, don’t forget to attach this script into a fullscreen UI Image. (You can make it fully transparent.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6d8386783a53b01563fe2cfed5a1c20/href">https://medium.com/media/d6d8386783a53b01563fe2cfed5a1c20/href</a></iframe><p>If our InputManager is ready to use, now we can implement our player ‘s movement. In the inspector panel, let’s click on the ‘Add Component’ button and create a script named ‘<em>PlayerMovement.cs</em>’. Let’s implement our base script with some variables and a reference to InputManager and a pivot point like below: (The pivot is just an empty Game Object, we will use it to rotate around later.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4f40326e860c1d8d4974b74a8e60394/href">https://medium.com/media/b4f40326e860c1d8d4974b74a8e60394/href</a></iframe><p>Let’s implement the Roll method which will be the core mechanic of the game. We determine a rotation axis according to the swipe direction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e58478c7df151c987ea4ce54a7bc2c3/href">https://medium.com/media/1e58478c7df151c987ea4ce54a7bc2c3/href</a></iframe><p>It should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-nzOGod_i1EoD59Ff-LwBQ.gif" /></figure><p>If you have noticed, the pivot is in the center of around our character, so the cube rotates around itself. We don’t want that. We want our character to rotate around a specific pivot according to its current state. For example: If our character stands still in a vertical position, it should rotate arount its feet. Let’s use a little bit logic.</p><p>For that purpose, we will use 6 contact walls which will represent our Up, Down, Left, Right, Front and Back directions. To illustrate, if a ray whose direction is the up of our Player touchs the Up or Down contact wall, it means we are in a Vertical posture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JX9r4FT38RCKS1yFzLKTAQ.png" /><figcaption>Visual representation of the contact walls.</figcaption></figure><p>Let’s turn that logic into code. First, we need to get a reference to layer of contact walls. After that, we should get direction vector that we will move towards. And lastly, we calculate the offset of the pivot according to our current posture (we will acquire it by using contact walls.) Finally, we re-position the pivot according to the offset and the move direction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2d62691cc3e026c4bad108f87c45617/href">https://medium.com/media/d2d62691cc3e026c4bad108f87c45617/href</a></iframe><p>After coding, let’s return to Unity Editor and create 6 big boxes to construct a larger cube. Then, rename the boxes according to their positions (i.e. if position of the box is on the Z axis, then rename it to “Z”.) Be sure that their colliders are set. After that, change all boxes’ layers to “ContactWall”, and assign this layer to ‘contactWallLayer’ variable of the player as follows.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F564985335%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F564985335&amp;image=http%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1168021241_640&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="640" height="360" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5e9330efd1e607fe39cc6d3692c5c7e/href">https://medium.com/media/a5e9330efd1e607fe39cc6d3692c5c7e/href</a></iframe><p>If you did this steps properly, then you should have an output like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*BGD2hAoDAmCkFhZifT4gFA.gif" /></figure><p>Well done, now you can roll your cube wherever you want! But we still have a problem: When rolling, the position and the rotation of the character is not fix. Even if there is a little deflection on the values, after lots of moves you would probably have to consider it.</p><p>We can fix this problem by using a ghost player and simulate everything on that, before we actually do the move for our actual player. First, copy the transform data of the player into ghost player. Second, do the roll action for ghost player in order to get an ideal result. Third, do the roll action for the real player. Lastly, copy the transform data of the ghost player into our actual player. To achieve that, let’s add some extra lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0540ff8b5cbfba5f9c34327147871d6c/href">https://medium.com/media/0540ff8b5cbfba5f9c34327147871d6c/href</a></iframe><p>Add an empty game object to the scene, rename it to “GhostPlayer”, and be sure you assigned its scale as same as the size of the player collider: In our case it is (1, 2, 1). After implementing these steps, you should have a result like following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*e33RnneRbjWEQCFhRlf-lg.gif" /></figure><p>The complete code is below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/019a8137c0a2ece6e41790e5d8a4f496/href">https://medium.com/media/019a8137c0a2ece6e41790e5d8a4f496/href</a></iframe><p>So, the first part of our Bloxorz game was like that. We learned how to roll a cube according to its current posture and given direction. In the second part, we will handle the level design and gameplay stuff. I hope this article had been useful for you. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67113d48415a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swipe Detection in Unity]]></title>
            <link>https://mstfmrt07.medium.com/swipe-detection-in-unity-5e8dc7a6fe17?source=rss-eb6c84c3f69b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e8dc7a6fe17</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[swipe-detection]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[gesture-recognition]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Mustafa Mert Aladağ]]></dc:creator>
            <pubDate>Fri, 14 May 2021 12:06:51 GMT</pubDate>
            <atom:updated>2021-05-14T12:06:51.838Z</atom:updated>
            <content:encoded><![CDATA[<p>Swipes are very popular and useful gestures for controlling our mobile games’ behaviors. It is very vital for our games to seamlessly integrate this mechanic, which is widely used in many genres from endless runner games to puzzle games. In this article, we will handle the swipe controls in Unity game engine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*SXZbe2lO8ByITJd_4DrTyg.gif" /></figure><p>First of all, let’s create a new project by clicking the ‘New’ button from Unity Hub, indicating the name and path of our project and choosing one of the 2D/3D options. After opening our project, right click into the ‘Assets’ folder and choose ‘Create C# Script’ option and create a new C# file named ‘InputManager.cs’. Since our class will use the Drag behavior, let’s apply the necessary libraries and interfaces to our class as follows. The drag behavior can be used on both computers and mobile devices without any problem, but we could also use the Touch class if we wanted it to be used only on devices that support touch. By the way, do not forget to import the EventSystems library to our script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac74f158ffa7e1344f5170b14da34901/href">https://medium.com/media/ac74f158ffa7e1344f5170b14da34901/href</a></iframe><p>After adding the IDragHandler, IBeginDragHandler and IEndDragHandler interfaces, our IDE will warn us to implement the methods required by these interfaces. Let’s click on the error that pops up and click on “Implement the interface” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CtOy5FX9K5DXNTuG9kaPQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3751a5c44d9b06135c9591f7533c81e4/href">https://medium.com/media/3751a5c44d9b06135c9591f7533c81e4/href</a></iframe><p>OnBeginDrag method is called when a drag behavior starts on the screen, the OnDrag method will be called while the drag behavior proceeds and lastly, the OnEndDrag method is called on the frame where the drag behavior ends.<br>We will operate our swipe gesture with 4 directions as up, down, right and left. For these purpose, creating an enum named Direction will benefit us later in our project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7696944b6c746499b6ac3d4b117bd6c/href">https://medium.com/media/c7696944b6c746499b6ac3d4b117bd6c/href</a></iframe><p>Now let’s add our global variables. A direction for our drag behavior, start position, end position, swipe threshold (minimum distance between start and end points to perform the drag behavior), and one bool variable to control whether dragging has started.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b476e2f14429529a898b0ad8dc3e5606/href">https://medium.com/media/b476e2f14429529a898b0ad8dc3e5606/href</a></iframe><p>Let’s assign the initial values ​​to our variables in Awake method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/023d575635e47af92b3264144e689538/href">https://medium.com/media/023d575635e47af92b3264144e689538/href</a></iframe><p>When the drag behavior starts, our draggingStarted value should be set to true, and our startPos variable should be assigned as the coordinates of the point where the event occurred.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e3a05eaef7499d887f7944a2826895e/href">https://medium.com/media/3e3a05eaef7499d887f7944a2826895e/href</a></iframe><p>During the drag behavior, if our draggingStarted value is true, we assign our end position as the current position of our Pointer, and we get the difference. If the magnitude of the difference vector is greater than the swipe threshold, we begin the direction determination process. If the x component of the difference vector is greater than the y component, we do a horizontal swipe.<br>Otherwise we do a vertical swipe. In horizontal swipe, if x component is greater than zero, our direction will become Right, otherwise Left. In vertical swipe, if y is greater than zero, our direction will become Up, otherwise Down. If our drag cannot exceed the swipe threshold, we set our direction value as None.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3362b5cc8b701105d69428f8f20e1daa/href">https://medium.com/media/3362b5cc8b701105d69428f8f20e1daa/href</a></iframe><p>When our drag behavior ends, if the draggingStarted value is true and our direction value is different from None; It indicates that we have obtained one of the four directions and that we can use this data in our game as we want. I chose to print the direction value into Debug console, but you can use it in your game as you wish.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cc16c3afd49129403277d862bf0ebb8/href">https://medium.com/media/9cc16c3afd49129403277d862bf0ebb8/href</a></iframe><p>The complete code is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36ba92400d5e91e6d792556ab2d45f49/href">https://medium.com/media/36ba92400d5e91e6d792556ab2d45f49/href</a></iframe><p>NOTE: Since Pointer events triggers on the UI objects, do not forget to attach this script into a Panel object which covers the entire screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ekAwbnRh1_5zcKzbbDh0uA.gif" /></figure><p>So, Swipe detection in Unity was basically like this. Of course, it can be implemented in various ways depending on your needs and creativity. I hope this article had been useful for you. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e8dc7a6fe17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity’de Kaydırma (Swipe) Algılama]]></title>
            <link>https://mstfmrt07.medium.com/unityde-kayd%C4%B1rma-swipe-alg%C4%B1lama-c372b92f7a5e?source=rss-eb6c84c3f69b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c372b92f7a5e</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[gesture-recognition]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[swipe]]></category>
            <dc:creator><![CDATA[Mustafa Mert Aladağ]]></dc:creator>
            <pubDate>Thu, 13 May 2021 22:47:51 GMT</pubDate>
            <atom:updated>2021-05-13T22:47:51.116Z</atom:updated>
            <content:encoded><![CDATA[<p>Ekranı kaydırma (swipe) hareketiyle kontrol günümüz mobil oyunlarında oldukça popüler ve kullanışlı bir yöntemdir. Sonsuz koşu oyunlarından puzzle oyunlarına kadar birçok oyun türünde kullanılmakta olan bu mekaniği oyunlara sorunsuz bir şekilde entegre etmek oyunlarımız için hayati önem taşır. Bu makalemizde Unity oyun motoru üzerinden ekran kaydırma kontrollerini işleyeceğiz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*SXZbe2lO8ByITJd_4DrTyg.gif" /></figure><p>Öncelikle Unity Hub’dan ‘New’ butonuna bastıktan sonra projemizin ismini ve konumunu belirleyip 2D/3D seçeneklerinden birini seçerek yeni bir proje oluşturalım. Projemiz açıldıktan sonra ‘Assets’ klasörü içerisine sağ tıklayıp ‘Create C# Script’ diyelim ve ‘InputManager.cs’ adında yeni bir C# dosyası oluşturalım. Kodumuz Drag (sürükleme) davranışını kullanacağından aşağıdaki gibi gerekli kütüphane ve (interface) arayüzleri kodumuza uygulayalım. Drag davranışı hem bilgisayarda hem de mobil cihazlarda sorunsuzca kullanılabilir, fakat sadece dokunma destekleyen cihazlarda kullanılmasını isteseydik Touch sınıfını da kullanabilirdik. EventSystems kütüphanesini eklemeyi de unutmayalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac74f158ffa7e1344f5170b14da34901/href">https://medium.com/media/ac74f158ffa7e1344f5170b14da34901/href</a></iframe><p>IDragHandler, IBeginDragHandler ve IEndDragHandler arayüzlerini ekledikten sonra kodumuz bu arayüzlerin gerektirdiği metotların kullanılması yönünde bir uyarı verecektir. Çıkan hatanın üzerine tıklayıp arabirimi uygula diyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CtOy5FX9K5DXNTuG9kaPQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3751a5c44d9b06135c9591f7533c81e4/href">https://medium.com/media/3751a5c44d9b06135c9591f7533c81e4/href</a></iframe><p>OnBeginDrag metodu ekranda bir sürükleme davranışı başladığında, OnDrag metodu sürükleme metodunun çalıştığı süre boyunca ve OnEndDrag metodu ise sürükleme davranışının bittiği frame’de çalışacaktır.</p><p>Biz kodumuzu yukarı, aşağı, sağ ve sol olmak üzere 4 yönde çalışacak şekilde yazacağız. Kaydırma yönümüzü belirtmek için Direction adında bir enum oluşturmak kodumuzun ilerleyen aşamalarında bize fayda sağlayacaktır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7696944b6c746499b6ac3d4b117bd6c/href">https://medium.com/media/c7696944b6c746499b6ac3d4b117bd6c/href</a></iframe><p>Şimdi global değişkenlerimizi ekleyelim. Sürükleme davranışımız için bir yön, başlangıç pozisyonu, bitiş pozisyonu, kaydırma eşiği (sürükleme davranışı için gereken başlangıç ve bitiş noktaları arasındaki minimum mesafe) ve sürüklemenin başlayıp başlamadığını kontrol etmek için bir adet bool değişken.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b476e2f14429529a898b0ad8dc3e5606/href">https://medium.com/media/b476e2f14429529a898b0ad8dc3e5606/href</a></iframe><p>Awake metodumuzda değişkenlerimize başlangıç değerlerimizi verelim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/023d575635e47af92b3264144e689538/href">https://medium.com/media/023d575635e47af92b3264144e689538/href</a></iframe><p>Sürükleme davranışı başladığında draggingStarted değerimiz true, startPos değişkenimiz ise etkinliğin gerçekleştiği noktanın koordinatları olarak atanmalıdır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e3a05eaef7499d887f7944a2826895e/href">https://medium.com/media/3e3a05eaef7499d887f7944a2826895e/href</a></iframe><p>Sürükleme davranışı esnasında ise draggingStarted değerimiz true ise bitiş pozisyonumuzu Pointer’ımızın şu anki konumuna atıyoruz, ve aradaki farkı alıyoruz. Eğer fark vektörünün büyüklüğü swipeTreshold adını verdiğimiz kaydırma eşiğinden büyük ise yön belirleme işlemine başlıyoruz. Fark vektörünün x bileşeni y bileşeninden büyük ise yatay, değilse dikey bir kaydırma yapıyoruz. X sıfırdan büyük ise sağa, değilse sola; y sıfırdan büyük ise yukarı, değilse aşağı yönde bir kaydırma yapıyoruz. Eğer kaydırma eşiğini geçmediysek direction değerimizi None olarak atıyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3362b5cc8b701105d69428f8f20e1daa/href">https://medium.com/media/3362b5cc8b701105d69428f8f20e1daa/href</a></iframe><p>Sürükleme davranışımız sona erdiğinde, eğer draggingStarted değeri true ve direction değerimiz None’dan farklı ise bu; dört yönden birini elde etmiş olduğumuzu ve bu veriyi oyunumuzda istediğimiz gibi kullanabileceğimizi gösterir. Ben konsola yazdırmayı tercih ettim fakat siz oyununuzda istediğiniz şekilde kullanabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cc16c3afd49129403277d862bf0ebb8/href">https://medium.com/media/9cc16c3afd49129403277d862bf0ebb8/href</a></iframe><p>Kodun tam hali aşağıdaki gibidir:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36ba92400d5e91e6d792556ab2d45f49/href">https://medium.com/media/36ba92400d5e91e6d792556ab2d45f49/href</a></iframe><p>NOT: Pointer eventleri arayüz üzerinde gerçekleştiğinden, bu kodu tüm ekranı kaplayan bir panel objesi üzerine iliştirmeyi unutmayın.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ekAwbnRh1_5zcKzbbDh0uA.gif" /></figure><p>Unity’de sürükleme algılama temel olarak bu şekildeydi. Tabii ki yaratıcılığınıza ve ihtiyaçlarınıza göre daha farklı şekillerde de uygulanabilir. Umarım bu makale sizler için faydalı olmuştur. Daha fazlası için lütfen takipte kalın.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c372b92f7a5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>