<script>
    import BannerTitle from "$lib/banner-title.svelte";
    import TableOfContents from "$lib/table-of-contents.svelte";
    import Video from "$lib/video.svelte";
</script>

<svelte:head>
    <title>2024-03-23 | denizk0461</title> 
</svelte:head>

<BannerTitle title="Project N5 Progress Update: 2024-03-23" subtitle="" banner="/projects/projectn5/devlog/previews/20240323.webp" />

<TableOfContents />

<p>I have quite a bit of free time on my hands until the next semester starts (in a few days...), and this leisure time has allowed me to continue working on my game a lot more than usual! I made quite a bit of progress that makes this game prototype feel slightly more polished and I'm really happy to share it here and now.</p>

<h2 id="attraction">Attraction &lt;3</h2>
<p>Collectibles are now attracted by the player once they're within a certain range (specified by a spherical <code>CollisionShape3D</code>) and are collected once they get close enough to the player – which is to say, once they collide with another, smaller spherical <code>CollisionShape3D</code>. The first try didn't work out amazingly, as the collectibles didn't want my character to intrude on their personal space though...</p>
<Video src="/projects/projectn5/devlog/20240323/personalspace.mp4" />

<p>I fixed that issue, and lowered the attraction velocity to test, but that resulted in a spooky haunting effect.</p>
<Video src="/projects/projectn5/devlog/20240323/haunting.mp4" />

<p>Here's another demonstration of that! I played around with PhantomCamera's dampening, which makes the haunting effect more evident. Also something I only came to notice then: my player jumps INSANELY high. Like 8x their height. This will be fixed later.</p>
<Video src="/projects/projectn5/devlog/20240323/high.mp4" />

<p>After tweaking the speed, I got some nice attracted collectibles.</p>
<Video src="/projects/projectn5/devlog/20240323/attraction_stuck.mp4" />

<p>One issue still remains though: when moving, the collectibles don't attract all the way into the player, therefore they don't get collected and fly next to the player until they stop moving.</p>
<p>I learned that <code>lerp()</code> was at fault (no offense!) – <code>lerp()</code> would work perfectly fine if the player were standing still, but since the player – and therefore, the target position – is moving, <code>lerp()</code> calculates a speed that cannot overcome the difference between the collectible position and the player.</p>
<p>I overcame this issue by increasing the weight of <code>lerp()</code> on every frame, thus increasing the speed linearly. This resulted in a very smooth attraction transition.</p>

<Video src="/projects/projectn5/devlog/20240323/attraction_smooth.mp4" />

<h2 id="rockets">rocket go boom</h2>
<p>I finally implemented enemy health – they can now take damage from weapons and die. But it felt so hollow without any impact. I wanted my rockets to explode. So I started working on that.</p>

<h3 id="rockets-1">Stage 1: Experimentation</h3>

<p>I first implemented a fairly basic particle effect using cube meshes. Not exactly photorealistic, but it gets the message across.</p>

<Video src="/projects/projectn5/devlog/20240323/explosion_0.mp4" />
<div class="image-subtitle-container">
    <span class="image-subtitle">boom</span>
</div>

<h3 id="rockets-2">Stage 2: Struggle Colliding</h3>

<p>I struggled EXTREMELY with getting the rockets to collide with the floor and walls. Oddly enough, they collided perfectly fine with the enemies! I was particularly confused because both the walls/floors and the enemies were types of <code>body</code> nodes, thus using the same piece of code to register a collision.</p>

<p>I looked up the issue online, to no avail, really, until I stumbled upon a thread about a completely different problem where someone advised to change the physics engine. I am, in fact, using a different physics engine – Jolt. So I figured, I'll go into the settings, and I'll change it, just to see what happens.</p>

<p>I briefly checked out Jolt's settings page... and then I saw something.</p>

<img src="/projects/projectn5/devlog/20240323/joltsettings.webp">

<p>"Areas Detect Static Bodies." This setting was OFF by default. This could actually apply, I figured, because my rockets are <code>Area3D</code>s and the walls/floors are <code>StaticBody3D</code> nodes. I turned it on, and... my issue was solved. Slightly frustrated, but more so amused and relieved, I continued work, happy that my code was fine and my solution worked.</p>

<p>I introduced an exported property that allows for setting the amount of collisions a projectile may experience before it despawns, thus allowing, for example, for the rocket to explode through a wall! I might use this in the future for the v3 rocket laucher.</p>

<Video src="/projects/projectn5/devlog/20240323/explosion_wall.mp4" />

<h3 id="rockets-3">Stage 3: Style</h3>

<p>One day after that, I was motivated to create a more convincing explosion. I watched a YouTube tutorial, and ultimately got something that looks quite nice:</p>

<Video src="/projects/projectn5/devlog/20240323/explosion_test.mp4" />

<Video src="/projects/projectn5/devlog/20240323/explosion_1.mp4" />

<p>Interesting observation: in Godot, you can use the "RAW" tab when picking a colour to set values above 100%. The explosions, for example, use red values between 300% and 500%, which, with my <code>WorldEnvironment</code> light setup, produces a glowing effect that's just perfect for explosions!</p>

<p>I also messed up my lighting setup in configuring this, which results in my character being extra shiny and the N5 Blaster to glow excessively, but that's ok, we can fix that later.</p>

<p>In a strange coincidence, <a href="https://youtu.be/rXwo0qcKJDk">Masahiro Sakurai released a video</a> about particle effects and the "right level of detail" just one day after I had started working on my explosion particle effects. Interesting video, by the way – I was not aware of how important scale is when designing VFX.</p>

<h2 id="shake">Camera Shake</h2>

<p>Anyway, I got to work on camera shake! Through a tiny bug that has already been fixed, I briefly got to experience something resembling a camera shake in my game while I was firing a rocket. I thought that was super cool, so I looked up camera shake and implemented it.</p>

<p>The tutorial I followed (a 2D tutorial, btw) used a strength value of 30. I figured that'd be too much, so I set it to 20, just in case.</p>

<Video src="/projects/projectn5/devlog/20240323/shake_0.mp4" />

<p>...I later set down the strength value to about 0.35.</p>

<p>I also implemented distance fade for the camera shake strength! The strength now depends on how close the player is to the explosion origin. An explosion far away won't shake the camera, but one close up has much more impact!</p>

<Video src="/projects/projectn5/devlog/20240323/shake_impact.mp4" />

<h2 id="new-weapon">A new weapon is in the works!</h2>

<p>I had a random burst inspiration recently while I was on the bus, and once I got home, I started modelling it. Introducing: a weapon that is unfinished and has no (finalised) name yet, but I'm still fairly proud of:</p>

<img src="/projects/projectn5/devlog/20240323/venom_front.webp">
<img src="/projects/projectn5/devlog/20240323/venom_back.webp">

<p>I'm thinking this could be a blaster of types, maybe similar to an N5 Blaster upgrade – two-handed. Though I think it should be separate from the N5 Blaster. It could also be a flamethrower, though I want the flamethrower to look a bit different, especially at the gun barrel.</p>

<p>I quite like the bolt at the back as well as the yellow gunmetal-ish colour of the bolt and the gun barrel. The body is far from finalised – I still have to figure out a fitting one. I do like the cutouts in the shape, however, so I'll probably keep them for the final body shape.</p>

<h2 id="camera">Camera Adjustments</h2>

<p>I also worked quite a bit on the camera, specifically how it moves! This is the main thing that, in my opinion, makes the current build feel just a bit more polished than the previous ones – relatively speaking, of course.</p>

<p>The camera now moves quicker and more smoothly in and out of the precision aiming mode, for example:</p>

<Video src="/projects/projectn5/devlog/20240323/camera_precision.mp4" />

<p>The level overview camera also moves in a much cooler way, using a quint transition type instead of the previous linear transition. I think using quint improves the look significantly.</p>

<Video src="/projects/projectn5/devlog/20240323/camera_overview.mp4" />

<p>Look at how smoothly the camera follows the player, even when the player jumps up a platform or falls down from one!</p>

<Video src="/projects/projectn5/devlog/20240323/camera_smooth.mp4" />

<p>The camera now sticks to the ground briefly when the player jumps, but it returns to the player once the player exceeds a certain height above the jump origin or falls lower than the starting point.</p>

<p>Also notice how, at the end of the video, I struggle to jump up the (admittedly massive) wall, but ultimately make it. Why is that? It's because I:</p>

<ol>
    <li>Adjusted the jump height to much more sensible values</li>
    <li>Implemented variable jump height, letting the player jump heigher the longer the jump button is pressed</li>
</ol>

<p>Of course, obligatory <i>I accidentally turned my game into a first-person shooter</i>, again. This view of the N5 Blaster actually reminds me of Metroid.</p>

<img src="/projects/projectn5/devlog/20240323/firstperson.webp">

<h2 id="unity">Looking down upon the mess I've created</h2>

<p>I'm really happy with my progress. As a bonus, here's an overview of my current testing level Unity.</p>

<img src="/projects/projectn5/devlog/20240323/unity_overview.webp">