LiteRally, an open source(ish) GeneRally fan-clone
Posted: Thu Feb 09, 2017 4:46 am
Hi ppl! I spent around a week making a little GeneRally open source clone in Unity. Just saying open sourceISH because it’s made in Unity, which is not open source, but all my code is!
Why?
So.. Me and my roommate are gamedevs and do various games, I am mostly doing gamejams and got pretty experienced I think in prototyping games quickly. One day we were playing various local mp games and were just ranting how crap they are, Generally was the only game that kept us playing and playing, and how master-able it was, we got better and better and more and more competitive! We just always wished it was a tiny bit better. That night, I just couldn’t wait for GR2, and I felt like.. srsly, I could make this in a week!
In less than 3 hours I made rudimentary tire friction model and then tried to pick surface data from pixels on the ground texture, just like GR, and it worked surprisingly well! And that was kind of the proof of concept to continue doing it. I thought of the name LIteRally instantly, and just kept using it. Tho, it’s not more “lite” than the original
The next day, I made a moddable system for tracks and objects, so that you can make your own tracks and even import custom meshes from .obj files. The other days I mostly spent tweaking, adding some tracks, and the menu. I have never done such a mod-friendly game before, so It’s also fun to learn something new. And of course.. I want to play the game with friends and enjoy it with community made mods!
What it has so far?
It has a simple driving model, ( I think ) more advanced and realistic than GR (not neceserally better!). It picks the grip value for each wheel directly from the track texture, but the tire friction is currently working according to contact speed, instead of contact force, which is incorrect, but I’ll improve it some day. At the moment you can play with 1 or 2 players on a few tracks I made so far. You can only select one track and race on it with 5 laps. Adding a season system and more modes would not be so difficult. Right now there is no system for calculating distance (I guess GR used the AI line for it), so I can’t make it “race by km” at the moment. Time-racing would not be hard to implement, I already track time for laptimes.
Why just 2 players? Fooor the moment.. I just want to first be sure to test it with 2 players, and then I can add 8, or 10 or 20 more… Because if I do that now, it could be a pain to change a lot of things.
Obviously there is no AI, I don’t know how necessary is it? I’ve personally never played it with AI because I always play with friends. It would not be hard to implement, but I know it will be hard to make it good, so it is most probably time wasted. But yeah, anyone is free to probe into the code and make some AI
There is no damage, fuel or tire wear yet, hence I didn’t bother with pits either. They are drawn on some tracks and there is data structure for them, I just don’t use them yet, need to get the core stuff better till I start working on pits
The menu is quite rudimentary, but functional, you can navigate using any controller in the same way you control the car, and it’s easy to add new options quickly if I need them in code. It’s like a tree structure that saves data in every node. Sure later on it would be nicer to do a proper UI
The sound is quite simple as well, just changing the sample pitch according to speed and throttle. The samples were kindly donated by my roommate from his game, Switchcars.
Height
Currently, there is no height variation on the map, (except by placing objects like jump ramps), but there is 2 ways I am thinking about:
One is importing a custom mesh, which would replace the “ground plane” if defined in the track file, but this would require the author to make it in a modelling software (and properly unwrap the uv for tires to work). I tried this myself and it actually is working pretty well.
The second would be using a heightmap to offset vertices on a dense grid mesh. I am kind of afraid if that’s gonna work well, I did stuff like that before and the terrain produced can be jagged due to limited pixel value (256 in 8bit per channel texture), so surface could be too bumpy and unpredictable. But I have to try first
MODDING
Right now, you can add tracks and custom track objects.
Tracks:
All data about the track is stored inside a text based .json file located inside the track folder. Each .json file is one track layout, meaning you can have multiple layouts for a single track texture. The track file is human-readable so you can edit values directly in a text editor. Essentially, you could take some piece, eg. pit positions of one track and copy into another just through the text file, which is really nice to have.
The .json file contains the positions of starting grid, portals (how I call checkpoints), pits, camera position and orientation and names and positions of track objects (for now, I will proly add more stuff)
The problem is that currently, the only way to VISUALLY edit tracks is in Unity editor using my scripts that can pick up objects in the scene and save to the json file. It would be cool to later make the in-game editor as well, so that a track modder doesn’t need to have Unity.
The wheel grip value is taken directly from the track texture underneath the wheel, see this doc for info about it. Essentially everything that is gray is tarmac, anything else at the moment is grass. I am thinking of maybe using a separate “surface” texture where surface type would be defined, so that “the look” can be made independently without thinking “is this gray gonna be gray enough to be tarmac?”
A funny coincidence happened in the feedback loop with pixel setting and getting: as you pass over the grass pixels and set “dirt tracks”, these pixels have a little bit of “bleed” and then you would pick that bled dirt pixel and place it again.. and you will continually stamp dirt even on the tarmac, as if the wheel caught dirt and you spelt it over the road, without me needing to program that s**t in
Track objects:
Track objects are .obj meshes in the GameData/Objects/ folder and are used as props around the track. They are loaded at start and placed through positions defined in the track file. Objects themselves also have a json definition file. To add a new custom object, you can simply copy an existing track object folder, rename it text-edit the .json file and add your own mesh. You can also define if the object will have no collision, mesh or box collider surrounding the mesh
One planned feature is to have “bundling”: track objects inside the Track folder as well, so that if you have a special mesh only for a single track, you can bundle it with the track, so for eg. if you want to remove the track, that there is no need to track down objects used by a particular track in the objects folder.
Other things:
Surface grip and resistance can be modded at the moment in the GameData/surfaces.json file
Cars can’t be modded at the moment, but implementing modding in the similar fashion to track objects would not be so hard, since all car data is (almost) already serializable, and could be put into a .json file. I just don’t feel confident exposing the stuff yet since I need to rethink some parts, rearrange the structure and expose some more stuff.
I mean.. it’s funny to say “can’t be modded” since it’s open and anyone can load it up in Unity and change scripts and rebuild the game, so.. EVERYTHING is moddable xD
One thing worth mentioning is that cars are designed in a modular-axle system, you can have as many axles with as many wheels you want and have each axle be powered, steered and/or use brakes or handbrakes, essentially you could make a forklift with rear axle steered if you wanted..
A few things I would like to implement other than what GR already has:
Day night cycle - I already did this numerous times for my other games, should be very easy to implement (cars already have headlights but are always off)
Weather - also did this before, would be easy to make it visually and affect tire grip on the whole map … buuut .. that said .. it would be muuuch better if the rain for example actually washed the dirt away from the track, the drying would happen gradually by driving over!!! But that would ofc require some experiments and time to make
Rally - It has “rally” in the name and you can’t rally? xD by which I mean.. point to point races with cars starting at intervals
Breakable parts - would be cool having some parts flying off, posing danger to other players + broken wings should affect aero for eg.
Tire choices - some tracks with mixed surfaces would need good strategic thinking
Cars I made:
Skewt - 70s rwd rally and GT car (currently the mascot of the game) - overall good, powersliding into every corner
Formulite - F1 like - lots of grip and power, aero for a lot of traction at high speeds, but can oversteer easily
Some car ideas I want to do:
80s 4wd group B car, very powerful, oversteery, good on gravel, awful brakes, awesome sound with pfffriyuyuyu turbo flutter
2000s wrc-like, powerful, well balanced, good grip on all surfaces, some aero
50s F1: superpowerful, s**t steering, essentially no brakes, terrible tires sliding everywhere, would require planning the racing line to like next 4 corners
east europeany car: slow, pretty much worst in every category, but offers close competition
all terrain: relatively slow, but good traction on all surfaces
Also, important notice: The game is quite crappy at the moment, expect bugs, some tracks are unfinished, etc. but consider this was made for a week of part time work.. I was just really impatient to share it with you ppl as soon as possible!
All source is here:
https://github.com/nothke/LiteRally
and you can grab the current build here:
https://drive.google.com/file/d/0B6-Kp1 ... sp=sharing
Also I am posting screenshots and updates on Twitter, so follow me there https://twitter.com/Nothke
I hope I will provoke some excitement from you fans, looking forward to hearing your suggestions and possible collaborations
Why?
So.. Me and my roommate are gamedevs and do various games, I am mostly doing gamejams and got pretty experienced I think in prototyping games quickly. One day we were playing various local mp games and were just ranting how crap they are, Generally was the only game that kept us playing and playing, and how master-able it was, we got better and better and more and more competitive! We just always wished it was a tiny bit better. That night, I just couldn’t wait for GR2, and I felt like.. srsly, I could make this in a week!
In less than 3 hours I made rudimentary tire friction model and then tried to pick surface data from pixels on the ground texture, just like GR, and it worked surprisingly well! And that was kind of the proof of concept to continue doing it. I thought of the name LIteRally instantly, and just kept using it. Tho, it’s not more “lite” than the original
The next day, I made a moddable system for tracks and objects, so that you can make your own tracks and even import custom meshes from .obj files. The other days I mostly spent tweaking, adding some tracks, and the menu. I have never done such a mod-friendly game before, so It’s also fun to learn something new. And of course.. I want to play the game with friends and enjoy it with community made mods!
What it has so far?
It has a simple driving model, ( I think ) more advanced and realistic than GR (not neceserally better!). It picks the grip value for each wheel directly from the track texture, but the tire friction is currently working according to contact speed, instead of contact force, which is incorrect, but I’ll improve it some day. At the moment you can play with 1 or 2 players on a few tracks I made so far. You can only select one track and race on it with 5 laps. Adding a season system and more modes would not be so difficult. Right now there is no system for calculating distance (I guess GR used the AI line for it), so I can’t make it “race by km” at the moment. Time-racing would not be hard to implement, I already track time for laptimes.
Why just 2 players? Fooor the moment.. I just want to first be sure to test it with 2 players, and then I can add 8, or 10 or 20 more… Because if I do that now, it could be a pain to change a lot of things.
Obviously there is no AI, I don’t know how necessary is it? I’ve personally never played it with AI because I always play with friends. It would not be hard to implement, but I know it will be hard to make it good, so it is most probably time wasted. But yeah, anyone is free to probe into the code and make some AI
There is no damage, fuel or tire wear yet, hence I didn’t bother with pits either. They are drawn on some tracks and there is data structure for them, I just don’t use them yet, need to get the core stuff better till I start working on pits
The menu is quite rudimentary, but functional, you can navigate using any controller in the same way you control the car, and it’s easy to add new options quickly if I need them in code. It’s like a tree structure that saves data in every node. Sure later on it would be nicer to do a proper UI
The sound is quite simple as well, just changing the sample pitch according to speed and throttle. The samples were kindly donated by my roommate from his game, Switchcars.
Height
Currently, there is no height variation on the map, (except by placing objects like jump ramps), but there is 2 ways I am thinking about:
One is importing a custom mesh, which would replace the “ground plane” if defined in the track file, but this would require the author to make it in a modelling software (and properly unwrap the uv for tires to work). I tried this myself and it actually is working pretty well.
The second would be using a heightmap to offset vertices on a dense grid mesh. I am kind of afraid if that’s gonna work well, I did stuff like that before and the terrain produced can be jagged due to limited pixel value (256 in 8bit per channel texture), so surface could be too bumpy and unpredictable. But I have to try first
MODDING
Right now, you can add tracks and custom track objects.
Tracks:
All data about the track is stored inside a text based .json file located inside the track folder. Each .json file is one track layout, meaning you can have multiple layouts for a single track texture. The track file is human-readable so you can edit values directly in a text editor. Essentially, you could take some piece, eg. pit positions of one track and copy into another just through the text file, which is really nice to have.
The .json file contains the positions of starting grid, portals (how I call checkpoints), pits, camera position and orientation and names and positions of track objects (for now, I will proly add more stuff)
The problem is that currently, the only way to VISUALLY edit tracks is in Unity editor using my scripts that can pick up objects in the scene and save to the json file. It would be cool to later make the in-game editor as well, so that a track modder doesn’t need to have Unity.
The wheel grip value is taken directly from the track texture underneath the wheel, see this doc for info about it. Essentially everything that is gray is tarmac, anything else at the moment is grass. I am thinking of maybe using a separate “surface” texture where surface type would be defined, so that “the look” can be made independently without thinking “is this gray gonna be gray enough to be tarmac?”
A funny coincidence happened in the feedback loop with pixel setting and getting: as you pass over the grass pixels and set “dirt tracks”, these pixels have a little bit of “bleed” and then you would pick that bled dirt pixel and place it again.. and you will continually stamp dirt even on the tarmac, as if the wheel caught dirt and you spelt it over the road, without me needing to program that s**t in
Track objects:
Track objects are .obj meshes in the GameData/Objects/ folder and are used as props around the track. They are loaded at start and placed through positions defined in the track file. Objects themselves also have a json definition file. To add a new custom object, you can simply copy an existing track object folder, rename it text-edit the .json file and add your own mesh. You can also define if the object will have no collision, mesh or box collider surrounding the mesh
One planned feature is to have “bundling”: track objects inside the Track folder as well, so that if you have a special mesh only for a single track, you can bundle it with the track, so for eg. if you want to remove the track, that there is no need to track down objects used by a particular track in the objects folder.
Other things:
Surface grip and resistance can be modded at the moment in the GameData/surfaces.json file
Cars can’t be modded at the moment, but implementing modding in the similar fashion to track objects would not be so hard, since all car data is (almost) already serializable, and could be put into a .json file. I just don’t feel confident exposing the stuff yet since I need to rethink some parts, rearrange the structure and expose some more stuff.
I mean.. it’s funny to say “can’t be modded” since it’s open and anyone can load it up in Unity and change scripts and rebuild the game, so.. EVERYTHING is moddable xD
One thing worth mentioning is that cars are designed in a modular-axle system, you can have as many axles with as many wheels you want and have each axle be powered, steered and/or use brakes or handbrakes, essentially you could make a forklift with rear axle steered if you wanted..
A few things I would like to implement other than what GR already has:
Day night cycle - I already did this numerous times for my other games, should be very easy to implement (cars already have headlights but are always off)
Weather - also did this before, would be easy to make it visually and affect tire grip on the whole map … buuut .. that said .. it would be muuuch better if the rain for example actually washed the dirt away from the track, the drying would happen gradually by driving over!!! But that would ofc require some experiments and time to make
Rally - It has “rally” in the name and you can’t rally? xD by which I mean.. point to point races with cars starting at intervals
Breakable parts - would be cool having some parts flying off, posing danger to other players + broken wings should affect aero for eg.
Tire choices - some tracks with mixed surfaces would need good strategic thinking
Cars I made:
Skewt - 70s rwd rally and GT car (currently the mascot of the game) - overall good, powersliding into every corner
Formulite - F1 like - lots of grip and power, aero for a lot of traction at high speeds, but can oversteer easily
Some car ideas I want to do:
80s 4wd group B car, very powerful, oversteery, good on gravel, awful brakes, awesome sound with pfffriyuyuyu turbo flutter
2000s wrc-like, powerful, well balanced, good grip on all surfaces, some aero
50s F1: superpowerful, s**t steering, essentially no brakes, terrible tires sliding everywhere, would require planning the racing line to like next 4 corners
east europeany car: slow, pretty much worst in every category, but offers close competition
all terrain: relatively slow, but good traction on all surfaces
Also, important notice: The game is quite crappy at the moment, expect bugs, some tracks are unfinished, etc. but consider this was made for a week of part time work.. I was just really impatient to share it with you ppl as soon as possible!
All source is here:
https://github.com/nothke/LiteRally
and you can grab the current build here:
https://drive.google.com/file/d/0B6-Kp1 ... sp=sharing
Also I am posting screenshots and updates on Twitter, so follow me there https://twitter.com/Nothke
I hope I will provoke some excitement from you fans, looking forward to hearing your suggestions and possible collaborations