<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Earth Guardian &#8211; INCD021</title>
	<atom:link href="https://incd021.com/category/programming/game_development/game/earth-guardian/feed/" rel="self" type="application/rss+xml" />
	<link>https://incd021.com</link>
	<description>Programming, thoughts, life  and art.</description>
	<lastBuildDate>Sun, 27 Oct 2024 18:04:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>Stencyl</title>
		<link>https://incd021.com/2013/11/17/stencyl/</link>
					<comments>https://incd021.com/2013/11/17/stencyl/#respond</comments>
		
		<dc:creator><![CDATA[INC $D021]]></dc:creator>
		<pubDate>Sun, 17 Nov 2013 12:19:54 +0000</pubDate>
				<category><![CDATA[Earth Guardian]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Stencyl]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[3d]]></category>
		<guid isPermaLink="false">http://incd021.com/?p=422</guid>

					<description><![CDATA[After some weeks thinking about life the universe and everything, I&#8217;m back. 🙂 I&#8217;ve spend some time making the basic stuff for a 2D game using Unity. Forcing Unity to....]]></description>
										<content:encoded><![CDATA[<p>After some weeks thinking about life the universe and everything, I&#8217;m back. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>I&#8217;ve spend some time making the basic stuff for a 2D game using Unity. Forcing Unity to make a 2D game have been a challenge, It works but I&#8217;ve spend a lot of time handling sprite sheet, animation and other standard stuff and not on the actual game. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Then by pure coincident I saw someone mentioning Stencyl on <a href="http://www.spiludvikling.dk">spiludvikling.dk</a> so I took a look, and if version 3.0 keeps it promises I guess I&#8217;ll be doing all my 2D games in Stencyl. Only thing about Stencyl I don&#8217;t like is the missing possibility to use C# and the still missing Android support <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> But for now it&#8217;s so easy to use, that I&#8217;ll gladly learn Scratch and objective C.<br />
Now that Unity version 4.3 is out, I&#8217;ll have to try it out to see if it&#8217;s as easy as they say, and if it is, I might switch back. If not, I&#8217;ll save Unity for my 3D needs <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Have fun! Now go make games!</p>
<p>&#8211; Henning</p>
]]></content:encoded>
					
					<wfw:commentRss>https://incd021.com/2013/11/17/stencyl/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Unity Draw Call Batching</title>
		<link>https://incd021.com/2013/09/16/unity-draw-call-batching/</link>
					<comments>https://incd021.com/2013/09/16/unity-draw-call-batching/#respond</comments>
		
		<dc:creator><![CDATA[INC $D021]]></dc:creator>
		<pubDate>Mon, 16 Sep 2013 15:42:33 +0000</pubDate>
				<category><![CDATA[Earth Guardian]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[ExecuteInEditMode]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[texture]]></category>
		<category><![CDATA[Unity draw call batching]]></category>
		<category><![CDATA[Unity draw calls]]></category>
		<category><![CDATA[UV]]></category>
		<guid isPermaLink="false">http://incd021.com/?p=410</guid>

					<description><![CDATA[I was having problems with Unity draw call batching. I&#8217;ve started on a small 2d game (Earth Guardian) and had made a small mockup and was already having problems with....]]></description>
										<content:encoded><![CDATA[<p>I was having problems with Unity draw call batching. I&#8217;ve started on a small 2d game (Earth Guardian) and had made a small mockup and was already having problems with the number of draw calls <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> It looked like I was getting an ekstra draw call for each sprite I created. So I didn&#8217;t know what I was doing..! So I had to find out what I was doing wrong.</p>
<p>Asking Google I found three possible things, that could be the problem.</p>
<ol>
<li>When creating my mesh I set mainTextureOffset and mainTextureScale.</li>
<li>My sprites use the build in transparent shader, which apperently could also kill the dynamic batching.</li>
<li>I set the material for all meshes to my spriteatlas texture. Not using shared materials.</li>
</ol>
<p><span style="line-height: 1.5;">The Code is as follows.</span></p>
<pre class="brush: actionscript3; gutter: true">public static GameObject CreateSprite(float x, float y, float width, float height, float scale, Material material)
    {
        y = materialHeight - y;
        float uvWidthUnit = 1f / materialWidth;
        float uvHeightUnit = 1f / materialHeight;

        float vertHeightScale = scale * (height / width);

        Mesh mesh = new Mesh();

        Vector3[] verts = new Vector3[4];
        Vector2[] uvs = new Vector2[4];
        int[] tris = new int[6] { 0, 1, 2, 2, 1, 3 };

        verts[0] = -Vector3.right * scale + Vector3.up * vertHeightScale;
        verts[1] = Vector3.right * scale + Vector3.up * vertHeightScale;
        verts[2] = -Vector3.right * scale - Vector3.up * vertHeightScale;
        verts[3] = Vector3.right * scale - Vector3.up * vertHeightScale;

        uvs[0] = new Vector2(0.0f, 1.0f);
        uvs[1] = new Vector2(1.0f, 1.0f);
        uvs[2] = new Vector2(0.0f, 0.0f);
        uvs[3] = new Vector2(1.0f, 0.0f);

        mesh.vertices = verts;
        mesh.triangles = tris;
        mesh.uv = uvs;

        mesh.RecalculateNormals();

        GameObject newMeshObject = new GameObject();
        newMeshObject.AddComponent&lt;MeshFilter&gt;().mesh = mesh;
        newMeshObject.AddComponent&lt;MeshRenderer&gt;();
        newMeshObject.renderer.material = material;
        newMeshObject.renderer.material.mainTextureOffset = new Vector2(uvWidthUnit * x, uvHeightUnit * y);
        newMeshObject.renderer.material.mainTextureScale = new Vector2(uvWidthUnit * width, uvWidthUnit * height);
        newMeshObject.AddComponent&lt;BoxCollider&gt;();
        Vector3 boxColliderSize = newMeshObject.GetComponent&lt;BoxCollider&gt;().size;
        boxColliderSize.z = 0.1f;
        newMeshObject.GetComponent&lt;BoxCollider&gt;().size = boxColliderSize;
        newMeshObject.AddComponent&lt;Rigidbody&gt;();
        Rigidbody rigidbody = newMeshObject.GetComponent&lt;Rigidbody&gt;();
        rigidbody.constraints = RigidbodyConstraints.FreezeAll;
        newMeshObject.isStatic = true;
        return newMeshObject;
    }</pre>
<p>So first I tried setting UV for the vertices instead of changing mainTextureOffset and mainTextureScale. For the first test I just removed the two lines, to see if the number of draw calls decreased.</p>
<p>The number of draw calls, on my main game screen, went down from 42 to 9 (I have some GUI taking up some calls).. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> And when I started shooting, a lot, the number of draw calls stayed solid at 9. So a real improvement. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Of cause now I had to test if changing the UV coordinates for each frame changes anything&#8230;. It didn&#8217;t effect the number of draw calls <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> This post from the <a href="http://answers.unity3d.com/questions/428183/modifying-maintextureoffset-increases-draw-calls.html">Unity Forum</a> says it all. So modifying mainTextureOffset and mainTextureScale is <strong>not</strong> the way to do it!  So no more testing, the UV way of doing things must be the way to go.</p>
<pre class="brush: actionscript3; gutter: true">[ExecuteInEditMode]
public class UVSetter : MonoBehaviour
{

    public float pixX;
    public float pixY;
    public float pixW;
    public float pixH;
    public float matrialSizeX;
    public float matrialSizeY;
    private Mesh theMesh;
    public bool updatable;
    // Use this for initialization
    void Start()
    {
        theMesh = transform.GetComponent&lt;MeshFilter&gt;().mesh;

        float uvx = pixX / matrialSizeX;
        float uvy = 1f - (pixY / matrialSizeY);
        float uvw = pixW / matrialSizeX;
        float uvh = pixH / matrialSizeY;

        Vector2[] newUVs = new Vector2[4];
        newUVs[0] = new Vector2(uvx, uvy);
        newUVs[3] = new Vector2(uvx, uvy + uvh);
        newUVs[2] = new Vector2(uvx + uvw, uvy);
        newUVs[1] = new Vector2(uvx + uvw, uvy + uvh);
        theMesh.uv = newUVs;
    }

    // Update is called once per frame
    void Update()
    {
        if (!updatable)
        {
            return; 
        }
        float uvx = pixX / matrialSizeX;
        float uvy = 1f - (pixY / matrialSizeY);
        float uvw = pixW / matrialSizeX;
        float uvh = pixH / matrialSizeY;

        Vector2[] newUVs = new Vector2[4];
        newUVs[0] = new Vector2(uvx, uvy);
        newUVs[3] = new Vector2(uvx, uvy + uvh);
        newUVs[2] = new Vector2(uvx + uvw, uvy);
        newUVs[1] = new Vector2(uvx + uvw, uvy + uvh);
        theMesh.uv = newUVs;
    }
}</pre>
<p>On a final note I just want to mention that, to get the editor to show the correct UV in the editor, I just added [ExecuteInEditMode] decoration to my UVSetter test class..</p>
<p>Now, go make games! <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>&#8211; Henning</p>
]]></content:encoded>
					
					<wfw:commentRss>https://incd021.com/2013/09/16/unity-draw-call-batching/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Gastorid, lacking layers.</title>
		<link>https://incd021.com/2013/09/08/gastorid-lacking-layers/</link>
					<comments>https://incd021.com/2013/09/08/gastorid-lacking-layers/#respond</comments>
		
		<dc:creator><![CDATA[INC $D021]]></dc:creator>
		<pubDate>Sun, 08 Sep 2013 20:10:29 +0000</pubDate>
				<category><![CDATA[Earth Guardian]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Gastorid]]></category>
		<category><![CDATA[Unity]]></category>
		<guid isPermaLink="false">http://incd021.com/?p=394</guid>

					<description><![CDATA[After testing Gastorid again and again, I don&#8217;t find it have the lasting gameplay I&#8217;m looking for. A change in game objective might help? But for now I can&#8217;t figure....]]></description>
										<content:encoded><![CDATA[<p>After testing Gastorid again and again, I don&#8217;t find it have the lasting gameplay I&#8217;m looking for. A change in game objective might help? But for now I can&#8217;t figure out what to change. :/<br />
Below you can see at short play through of the game as it is for now.<br />
<iframe title="Gastorid - Early prototyping - GamePlay" width="768" height="576" src="https://www.youtube.com/embed/gQUF0N_JZjE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
I don&#8217;t think that making specific levels design/setups, will add to the gameplay (for now it&#8217;s just random). Something more is needed. I might get some ideas in time, and try to add them.</p>
<p>Even though I hate abandoning a project, for a while, i hope that working on other things, will give me some new inspirations. If not, I will have learned a lot, I can use in my next project.</p>
<p>Working with touch devices is something completely different than making mouse/keyboard controlled games. The biggest challenge I have found is that I will cover a large section of the screen when clicking on the left part of the screen (I&#8217;m right handed). So some simple game ideas just won&#8217;t work, or the controls has to be redesigned&#8230; Just writhing the lase section gave me an idea that I have to test. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Got to go and the a new control for another prototype that I&#8217;m working on.</p>
<p>Have fun, and go make game!</p>
<p>&#8211; Henning</p>
]]></content:encoded>
					
					<wfw:commentRss>https://incd021.com/2013/09/08/gastorid-lacking-layers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Page Caching using Disk: Enhanced 

Served from: incd021.com @ 2025-05-17 20:49:34 by W3 Total Cache
-->