State of Project KW (25 June 2023)


Welp. This week has been a week.

I couldn’t post a devlog yesterday. My computer had a complete breakdown when I added an extra 16GB RAM, causing my CPU to overheat to a point it was powering off and that caused my OS drive to be corrupted. Why did it overheat? Well, turns out my CPU fan died. So I had to invest in a new liquid cooling system 🙃 Finally back up and running now. So there we go.

Good news though!

It took a while, but I was able to recreate the orbit camera effect you see in the original game when you’re either in the main menu, or in the pause menu. This is good news, as we’ll need this effect when you pause the game, because the idea is to disorient you so that you’re not able to focus for too long so that you don’t solve the game while bypassing the in-game timer. But it has a benefit that it allows a complete overview of the level. It’s clever, I’ll grant them that.

How it works

It was a pain in the ass. First, I tried to use some weird formula using a botched SIN/COS combination, which ended up looking horrendous. Then I tried using fixed Cinemachine virtual cameras and randomly selecting which should be the priority, but this caused noticeable jitter and freezing whenever a new camera was selected as the main camera. Then I thought about using Slerp, but realised I have no idea how that even works.

The answer was so incredibly simple, it’s amazing that it wasn’t the first thing I tried. There’s an empty game object in the world, located at the level’s average center (for the menu, it’s at the origin). This object has a child, positioned at an offset where the entire level is visible. This child has a camera.

All I do is rotate the parent on all 3 axes at a fixed rate. The FOV is then PingPong’d between a min and max value.

I swear to you, that’s literally it. I will show you the complete Update method:

private void Update()
{
    if (_enableRotation)
    {
        _euler += _rotationSpeed * Time.deltaTime;
        _euler = Repeat(_euler);
        transform.localEulerAngles = _euler;
    }

    if (_enableFovPingPong && _fovLoopTime != 0.0f)
    {
        float t = Mathf.PingPong(Time.time / _fovLoopTime, 1);
        _camera.m_Lens.FieldOfView = Mathf.Lerp(_fovRange.x, _fovRange.y, _fovSmoothing.Evaluate(t));
    }
}

The Repeat function just wraps the vector so that it’s 0-360, since if we keep adding infinitely we’ll eventually hit float inaccuracies and we don’t want that happening.

It’s ridiculously simple. And it looks phenomenal!

What next?

Frankly I’m winging it at this point. We got basic movement, we got the foundations of level loading, we got the orbit camera. Maybe next I can try to load in the items such as coins and keys (and the exit of course). We’ll see what I feel motivated for this week.

Keep on rollin’.

Leave a comment

Log in with itch.io to leave a comment.