Devlog 1. SS25/ RacR 0.1


SS25, now called RacR, is my first Unity game dev project. Before starting this project  I had no experience with C# and almost none with Unity. I had spent time going through all the Unity tutorials and knew a little bit about a lot of things but I wanted to learn how it all comes together to make a game. It needed fairly simple game-play and I have fond memories of Super Sprint by Atari form the 1980s so that's what I chose.

I unashamedly used Claude and Copilot for all of the coding and for help plugging the code into Unity. I have been using the free versions of both, initially Claude Sonnet 3.5 but the free account reverted to Haiku after a day or two. I found Sonnet to be much better, but Haiku just needed more atomic queries.

Stage 1. Basic Art

Before setting up Unity I built a the track image in Inkscape, which I needed to learn first. It became clear making good looking art was going to take a while so I stopped as soon as I had something to work with and grabbed a car off the web. I'll go back to the art when the functionality is working.

Stage 2. Basic Prototype

I started by asking the AI questions about the code structure for a Super Sprint game. I needed to tell it specifically to not write code at this stage. I only had a vague idea of 'separation of concerns' at this stage so these initial questions clearly set up a path forward. At this stage I chose to start with a Vehicle Controller script to attached to the car and triggers set up in the map for race-track, barriers, grass, and pits.

My first goal was to have a track in the scene and a car moving like Super Sprint around in the scene. I asked AI to write a basic script to attach to and control the car like the Super Sprint Atari game. I gave the AI a tonne of detail with each query including Unity version number etc, and I asked it to annotate extensively. 

I took the generated code attached it to the car and tested it, then sent the code back into the AI with questions about things I didn't know and to improve it. After many iterations, including many hallucinations on both sides of the screen, we came up with the following car variables. 

normalSpeed, normalAcceleration,  -to control movement

grassSpeedMultiplier, pitsSpeedMultiplier, grassAccelMultiplier, -to reduce speed when off track

turnSpeed, minSpeedToTurn, -to control turning

lateralDrag, -to control drift

backwardSpeedMultiplier, -to control reverse and to reverse steering

grassTurnMultiplier, pitsTurnMultiplier, -to control turning off track

baseDrag. -to control coasting and natural drag

There is no way of changing any of these variables in-game at this stage but they were set up as public fields on knowing that eventually they would be adjustable.

There were many iterations to get to this point but I found I needed to hold the AI back more than anything else, it kept trying to add a timing system etc. Getting to this stage was fairly easy because there is not much going on but it was good to have a working prototype.

Stage 3. Timing, UI, Camera

This step took me a while to understand. Initially the Timer was part of the Vehicle Controller and the UI was all mixed up but eventually I realized this is why we split things up. So I completely ignored UI for a bit, and just used the console to check that the timer was working. Once it was working it was fairly easy to work out how to create, Best Lap, and Last Lap times. These times obviously did not persist after game exit so that went on the To-Do list.

It also took me a while to find the Edge Collider, previously I had been trying to get the Polygon Collider to do everything but the 'on-exits' were confusing me. The Polygon Collider was good for the barriers and the Edge Collider/Trigger was good for the Start/Finish line. 

I had basic timing working but I remembered from playing Super Sprint that it was fun to measure/see your improvement in lap times after many laps. Best and Last times would not be enough for this and I wanted to add more detail about average laps times which I thought would be easy. 

Averaging lap times obviously requires remembering lap times and there are many ways of doing this in code. I have a little bit of experience in Python and data so the AI and I confused ourselves for a while but eventually landed on Enqueuing after trying Lists and Arrays.

This is an example of an AI query at this stage...

    private void UpdateConsecutiveLapsAverage(float completedLapTime)
    { consecutiveLaps.Enqueue(completedLapTime);
        if (consecutiveLaps.Count > 3)
        { consecutiveLaps.Dequeue();}
        if (consecutiveLaps.Count == 3)
        { float avgTime = consecutiveLaps.Average();
            if (avgTime < bestConsecutive3LapAverage)
            { bestConsecutive3LapAverage = avgTime;
                SaveSystem.Instance?.UpdateBestConsecutive3LapTime(bestConsecutive3LapAverage);
                onBestConsecutive3LapUpdated?.Invoke(bestConsecutive3LapAverage);
            }}}
This method uses enqueue/dequeue, please explain this to me and compare it to other methods.

(It's not rocket science, anything that the UI generated that I didn't understand I would just directly ask about until I had what I needed.)

After I had the Times I needed setting up the UI was pretty easy. I intentionally left everything as default in the UI, function was the only focus. I used Text Mesh Pro knowing that this will soon/eventually be obsolete because I started the project in Unity 2022.3 without knowing about the new UI Toolkit. The AI suggested the UI have it's own script too.

At this stage the Timer was still quite buggy. For example, it was possible to drive the wrong way over the finish line to get a time but it was good enough for the prototype.

When the UI was installed the fact that the main camera was static really stood out and looked really bad. I had recently done a tutorial about first-person camera controllers so I knew basically what I needed to do and got the AI to write a Camera Controller script. It is just a rectangle (the camera) clamped inside a rectangle (the map) that follows the car with some smoothing effects.

Stage 4. Publish the first prototype.

Now that all the basics were finish I wanted to do a bit of testing and I wanted to work out how to export a game which I had never done before. As soon as I realized itch.io has the option to play games in browser I had my answer. The original Super Sprint was a keyboard game so I haven't been thinking about mobile play, so itch.io is great for now. The first prototype, called SS25, was then released.


This brings us up to the release of SS25, I'll write another post about the lead up to the release of RacR0.1 soon.

Files

RacR 0.1.zip Play in browser
30 days ago

Leave a comment

Log in with itch.io to leave a comment.