Venturi DevLog #3 Map Editor, Scripting, and Ship Mechanics!
follow us at @VenturiGame and Like us on Facebook!
We've spent the last several months being less than talkative about Venturi. Truth is we've been focusing all of our time on development of the game and not enough on extending out to the community to include you all in what we're working on. The programmers would like to start a weekly blog showing what we're working on and our ideas for the future. This is our inaugural post so it's going to be a bit long. There is a lot to talk about! To start things off we're going to go over how we're building two crucial pieces of Venturi: the modding system and space ship mechanics.
We started Venturi wanting the game to be moddable and scriptable so that our players could easily add in their own content. However, during early development, it became increasingly apparent that Unity doesn't inherently support modding. Unity scene files are built-in to the game, and there's no way to add more of them to the game other than modifying the source project and rebuilding the entire game—not an ideal way to support modding. Unity does have an “asset bundle” system that allows content to be tacked on to the game externally and loaded in, but the bundles also can't be created outside of the source project—still a no-go for modding support.
So, we had to figure out our own way to let the community create their own levels, missions, ships, and items. We debated between using third party editors, exporting Unity scenes and prefabs, and using text-based serialization. In the end, we decided that the only way to do this right was to create our own level editor, accessible from inside the game.
Building our own editor has proven to be a challenge, but for the last five months we've been grinding through the code to create an intuitive world builder with custom JSON serialization. Under the hood we've pretty much built a simplified Unity editor inside of Unity itself: There's a library of objects to place in your levels, a list to show objects currently in the level, an inspector to modify any relevant properties on objects, and a console to display any messages from the game.
The editor runs in real-time, so no baking or compiling is required. When you want to test out your level, you can simply click the “Play” button at any time and the game will instantly jump into play mode. Clicking the “Stop button” while in this mode will return you back to the level's state before entering play mode. Levels are saved externally as JSON files, so content can be easily swapped in and out at any time.
The level editor is great for constructing basic levels, but, by itself, it doesn't allow for very dynamic content. You can place objects in the world and let them play out their natural actions, but not much will happen beyond that. We wanted designers to be able to use our level editor to create fully-functioning levels, complete with goals, dynamic environments, and character interaction, but the editor in its current state wasn't enough. So, we integrated a Lua scripting system to handle events and action response within a level (Lua is a wonderful scripting language that is the framework for lightweight and pain-free modding support in many, many games.). Every level in Venturi can have optional Lua scripts associated with it that manage desired actions in response to game events. A very simple example would be turning a light on and off as the player enters and leaves a specified region in the level:
A spherical region is placed next to a mine. We want to turn on a warning light when the player enters this region, and then turn it off when they leave the region.
We need to reference the light from our Lua script, so we'll take a note that its unique object identifier is 3 (found in the top-right, on the inspector panel). This ID will never change. So, using that, here's our Lua code:
And here is the result when we run the level:
Yay, it works! This system of Lua scripting is very powerful, and it will let designers create very unique and dynamic content in their levels. In fact, the game's entire single-player campaign will be made with it—the community can use the same tools that we did to make the game!
As we've said before, player choice is a huge part of Venturi. We're working to make a game that will be sculpted by the player's decisions. One of the major game mechanics we're working on right now is how players can build and customize their ship to fit a particular playstyle. We've created a modular ship system which allows you to mount different weapons, thrusters, and upgrades, changing how the ship feels and fights. You can create a brawler type ship with short range weapons, strong armor, and front facing shields. Charge in to the enemy (collisions do damage!) and pummel them with EMP blasts and dual mounted shotguns. Or if you like to stay farther away from the battle, you can opt for a long range but slow-firing railgun and powerful thrusters to keep you away from danger. Stealthier players can cloak their ship, sneak up on a player, and engage electronic warfare drones, disabling the enemy's thrusters and weapons and leaving them defenseless.
We made a choice early on to not have a traditional leveling system like most RPGs, where you grind away at enemies and quests until you gain enough experience to progress. Instead we wanted to allow the players to move through the game at their own pace and let their skill be the deciding factor of how fast they can play. This presented some challenges for us, such as how we were going to prevent players from using overpowered weapons or devices that would normally be meant for a higher “level” player. We designed a system that gives every ship hull an amount of power that can be utilized for outfitting. Every component you mount to your ship requires power to operate, meaning that careful consideration has to go into creating a ship that's perfect for the role it plays. Thrusters, shields, weapons, utility devices, and upgrade modules all draw from your power reserves, which gives us a wide range of build options while still maintaining balance. You can have a fast and nimble ship with power-hungry thrusters, but you'll have to sacrifice shield or weapon strength to compensate. Or you can go with a slow moving but hard hitting vessel that's vulnerable to something that can out-maneuver it.
Building this power system has given us new and exciting possibilities for designing the different enemies you'll face. We've been brainstorming ships that uniquely use this system, such as a swarm of small Juht ships that only have a single but highly damaging EMP rifle that overloads their ship's capacitors every time they use it. Any time the ship fires, the rest of the modules are disabled until the caps can cool down and begin recharging.
There will be thousands of possible ship combinations, and we're looking forward to seeing the different ways our community uses the modular system! And, using our modding and scripting system, you can even create your own modules and devices!
Another big part of Venturi we've been focusing on is realistic physics. Everything in the game—from projectiles shot out of weapons, all the way up to ship movement and turning—is as physically accurate as possible. This was very important for us to include, as it allows for very dynamic gameplay. For example, missiles fired from missile launchers will accelerate based on their attached rockets, projectiles can have their paths affected by external forces, and ships move and turn solely by firing their thrusters.
When it came to using thrusters to make ships turn to face a target point, we quickly ran into issues with oscillations. In our initial attempts, when the ship wasn't facing the desired direction, we'd apply a torque to accelerate it in the right direction. When it was facing the desired direction, we'd apply no torque. Seemed like a trivial solution! But, as we rapidly discovered, the problem is that this model is exactly the same as that of a harmonic oscillator. Like a pendulum, the ship experiences no torque when at its desired state, but it has maximum momentum at that point. Because of this, it overshoots its target and has to torque in the opposite direction to make up for it. But it does exactly the same thing again! It overshoots its target once more and has to backtrack again. This cycle repeats indefinitely, and the ship never comes to rest when facing its desired direction.
Obviously, this wasn't what we were looking for. We needed ships to turn to face their desired direction and come to a stop naturally. To solve this, we implemented a PID controller for our thrusters, resulting in a physically accurate movement model. Here's what turning a ship looks like (slowed down 3x) using a PID controller:
That about wraps up our first programmers' blog! Thanks for taking the time to look at our page, and we hope you enjoyed everything in this post! Please follow us at @VenturiGame and Like us on Facebook! And of course, subscribe and leave us some feedback below. We'd love to hear what you think of the game -- thank you!