This week I added the ability to import splines from max. We can now create a more complex track design in 3ds Max and line points up more precisely with the other world geometry, then simply export the spline as a .obj file.
Spline viewed in Max:
Generated track viewed in Unity:
Another thing I did this week was attempt to make the player’s velocity constant throughout the track. Before, the player would travel faster or slower depending on how the Bézier spline points were placed. This system is better now, but not quite in a final state yet.
Finally, I made the track width a little more flexible. We used to only be able to set the width of the entire track as a single value. Our artists asked for the ability to tweak the width of the track at certain points, so I added that feature this week as well.
Next week I hope to sort out the player movement, as that is such an important system and needs a good amount of TLC before I’d consider it to be good enough.
This week was mostly spent improving the prototype in various ways. Firstly, we received the feedback that the auto acceleration of the player should be removed, since when you let go of the controls the ship would keep going on its own and it felt like the player didn’t even have to try to succeed.
That was an easy change, and the game did feel much more like an active racing game.
Another thing that I changed was the way your input is mapped to the player’s movement when the player is upside down. Some play testers told us that when upside down it was confusing to have the controls be backwards. After switching around the controls when upside down, we got feedback from other play testers that they liked it better before. Because of this we will likely make this an option you can set before a game starts.
Next I made the projectiles that the player fires move along the track. Before, the player just shot wherever the mouse cursor was – which clearly wasn’t anywhere near good enough. Really, that was only in there because we hadn’t removed it after deciding to ditch mouse controlled shooting. After making this change shooting obstacles became much easier.
Throughout the week I also fixed bugs here and there and made the game in general nicer and more fun to play. I also cleaned up a few scripts to make creating new levels easier for everyone on the team. Part of that was just making scripts find the objects they need a reference to themselves, so that we don’t have to, for example, drag the player ship into 12 different scripts manually on a new level.
Next week I plan on continuing to make the game feel nicer to play and continuing to add additional features along the way.
After adding the ability to twist and curve the track, I needed to update the player movement script to take those changes into account. The player’s position and rotation are now effected by which part of the track they are on, as you can see below.
I also added the ability for the player to dodge left and right by double tapping a direction key.
Finally I added controls for how much acceleration power and braking power the player has. This way we can tweak both values separately and even adjust them in scripts (for example for a speed boost, or for an EMP which disables your brakes momentarily)
Recently I’ve been working on a feature on the Bézier Spline script that allows us to control the way the track twists, so that we can have barrel-roll-type features on the track.
Getting everything to work right and be correctly serialized/deserialized took way longer than expected. I’d still like to make the system more robust, but since we’re in the prototyping phase I’ll leave it as is for now.
I also added the option to the script to control the “curve” of the track. This can be set to a positive or negative value, resulting in the following effects:
The next step is to get the player to follow the twisting and curving of the track.
After getting the track generator up and running, the next logical step was to align the player’s movement to the newly generated track. There were a few ways I considered going about this, but the simplest option was for the player to be to store how far along the track they are (from 0.0f – 1.0f), with the value wrapping every time the player completes a lap. Each frame a certain amount can be added to that value, based in part on the user’s input.
I also store how far to the left or right of center the player is on the track. I can therefore easily prevent them from falling off the edges by simply ensuring that that value is less than half of the track width.
Here’s what the movement in game looks like now. You might notice that the player movement is a bit jittery, this is a problem we are currently looking into.
You can play our first prototype build here.
This week I implemented a Bézier spline path generation tool in Unity to use for track generation. With this tool the user can, in real time; enable or disable looping (when enabled the last point is aligned with the first), set the width of the generated path, set the number of segments generated both along the length of the path as well as across the width of the path, and change the type of each point.
The three types of points available are the standard ones you’d find in any vector graphics image editing software: Free, Aligned, and Mirrored.
Free Bézier Point
Aligned Bézier Point
Mirrored Bézier Point
The free point has no restrictions on it, which can result in sharp, abrupt changes in your path. The second type shown, the aligned point, restricts the two handles to have the exact opposite directions of each other, but allows different lengths, resulting in smoother corners but still some flexibility. The mirrored type is like the aligned, except for that it requires that the handles to have the same length. This results in the smoothest corners of all three options, but it can be too restrictive for certain situations.
I must say thank you to Catlike Coding for putting together this great tutorial – it was a great resource for getting started on this topic.
The next steps will be aligning the direction of ships to the section of the track they are on and preventing them from falling off the edges.