{"id":530,"date":"2026-03-05T12:25:40","date_gmt":"2026-03-05T12:25:40","guid":{"rendered":"https:\/\/sites.wsagames.com\/om3g24\/?p=530"},"modified":"2026-10-06T13:37:25","modified_gmt":"2026-10-06T13:37:25","slug":"development-log-03","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/om3g24\/2026\/03\/05\/development-log-03\/","title":{"rendered":"Development Log 03 &#8211; Rewriting the Prototype"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Due to runtime errors and inconsistencies with my programming, leading up to our first playtest I chose to rewrite the script to the peacock minigame from scratch, using examples from <a href=\"https:\/\/www.youtube.com\/watch?v=Xss4__kgYiY\">CodeMonkey<\/a> as a more firm reference. However, I kept all of the in-engine Unity assets and materials\/shader logic intact.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"text-decoration: underline\">Rewriting the Script<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To begin, I corrected my inital error of having the script be built around the shape node that held the peacock material: rather, it should have been constructed around the camera, as it is what fires the raycast signal to the material.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"793\" height=\"534\" src=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-16.png\" alt=\"\" class=\"wp-image-781\" srcset=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-16.png 793w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-16-300x202.png 300w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-16-768x517.png 768w\" sizes=\"(max-width: 793px) 100vw, 793px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the script is very similar to that of <a href=\"https:\/\/sites.wsagames.com\/om3g24\/2026\/03\/05\/development-log-02\/\">Development Log 2<\/a>, but greatly restructured. To start, the camera in this version does not have to be fetched because it is being built within the camera node.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The DullMask layer is instatiated as &#8216;maskTextureBase&#8217;, the PNG texture brushTex (used for painting the peacock) is instantiated as &#8216;brush&#8217;, and the peacock material shader as &#8216;material&#8217;. <\/li>\n\n\n\n<li>All of the relevant assets relating to textures and materials are assigned upon startup. This includes:\n<ul class=\"wp-block-list\">\n<li>maskTexture as a Texture2D class, which holds the width and hieght co-ordinates of the DullMask layer.<\/li>\n\n\n\n<li>retrieving the pixel colour data for the texture via getter and setter methods.<\/li>\n\n\n\n<li>setting the material texture as DullMask to overlay it onto the peacock material.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"873\" height=\"544\" src=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-18.png\" alt=\"\" class=\"wp-image-792\" srcset=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-18.png 873w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-18-300x187.png 300w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-18-768x479.png 768w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Next is a revised iteration of the raycast script, in which upon lcicking the left mouse button, a raycast laser will be fired from the camera and onto the material at the mouse cursor&#8217;s positional value.<\/li>\n\n\n\n<li>The output co-ordinates of where the raycast hits the material are stored in variable &#8216;textureCoord&#8217;, and then are multiplied by the width and height values of the mask texture in the variables pixelX and pixelY.<\/li>\n\n\n\n<li>These numbers are then stored in a new variable, paintPixelPosition, which represents the pixels we want to remove the mask layer from. The debug log outputs these alongside the UV co-ordinates of the raycast.<\/li>\n\n\n\n<li>&#8216;paintPixelDistance&#8217; exists to avoid painting too close to previous positions, which can very easily cause runtime errors. By subtracting the paintPixelPosition values from &#8216;_lastPaintPixelPosition&#8217;, setting a new integer &#8216;maxPaintDistance&#8217; to a value of 7, and returning if maxPaintDistance ever exceeds paintPixelDistance, we can ensure that this never becomes an issue.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"796\" height=\"378\" src=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-20.png\" alt=\"\" class=\"wp-image-798\" srcset=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-20.png 796w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-20-300x142.png 300w, https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/image-20-768x365.png 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Finally, the script that operates the brush itself. The brush is instantiated by creating values &#8216;squareSize&#8217; and &#8216;pixelXOffset&#8217;\/&#8217;pixelYOffset&#8217; and applying them to the brush texture from earlier. <\/li>\n\n\n\n<li>Using for statements, we can create a small facet of script that paints black pixels over the maskTexture in the position of the brush texture, therefore removing the pixels from the dullMask overlay. Using &#8220;maskTexture.Apply()&#8221;, we apply this directly to the mask texture; and the minigame now functions as intended.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"832\" style=\"aspect-ratio: 1140 \/ 832;\" width=\"1140\" controls src=\"https:\/\/sites.wsagames.com\/om3g24\/wp-content\/uploads\/sites\/55\/2026\/03\/20260514-0845-57.8476210.mp4\"><\/video><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Due to runtime errors and inconsistencies with my programming, leading up to our first playtest I chose to rewrite the script to the peacock minigame from scratch, using examples from CodeMonkey as a more firm reference. However, I kept all of the in-engine Unity assets and materials\/shader logic intact. Rewriting the Script To begin, I [&hellip;]<\/p>\n","protected":false},"author":46,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[45,1,44],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-dev-log","category-y2-parent","category-y2s2"],"_links":{"self":[{"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":22,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/posts\/530\/revisions\/803"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/om3g24\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}