Basic Level Modding - X-Hax/SA2BModdingGuide GitHub Wiki

Introduction

Welcome to the Basic Level Modding tutorial!

In this tutorial, you will learn how to create a level for Sonic Adventure 2 either from scratch or using a map downloaded from the internet. Using the modding tools listed below, you will create a simple level with custom geometry, textures, and collision. To add more advanced features to your level, such as rails, loops, enemies, and more, please visit the Advanced Level Modding tutorial (Coming Soon).

Estimated Time: 20-30 Minutes (It will get faster once you learn)

If you need help at any point in the tutorial, feel free to visit the X-Hax Discord and leave questions there.

Youtube Links

Requirements

Please download and install these tools before you start:

  • SATools - The Sonic Adventure modding toolkit
  • Blender - A 3D editor (BLENDER 3+ REQUIRED)
  • SA2ModLoader - Mod loader that will run our mod
  • My Level Mod - A custom level template mod that makes importing levels easy
  • SonicAdventureBlenderIO - A Blender addon to add Sonic Adventure support. (install guide in tutorial)

Preparation

Before you start creating your level, its important that you prepare the textures that you would like to use in your level. To do this, we will be using the "Texture Editor" included in the SA Tools Hub. In this tutorial, you have two options: if you would like to save time, you can use an existing texture pack that's in the game, or you create your own from scratch.

Begin by opening the SA Tools Hub, and then opening the "Texture Editor" on the right. Then, move on to the option below you would like to use.

SaToolsHub Window

Note: While optional for this tutorial, you can get access to more in-game assets by creating a "project" in SA Tools through clicking on "New Project." This will rip many assets from the game, such as Sonic's model, existing level files, and more. Also, throughout the tutorial, you will hear terms such as "PRS" and "PAK," which are just proprietary file formats Sonic Adventure uses for textures.

(Option 1) Using an Existing Texture Pack

To use an existing texture pack, select "File -> Open" and navigate to the 'resources\gd_PC' folder in your Sonic Adventure 2 install (Should be "C:\Program Files (x86)\Steam\steamapps\common\Sonic Adventure 2\resource\gd_PC").

Then, select any file named "landtx##.prs." The ##'s correlate with Sonic Adventure's level IDs, which you can find here.

Texture Editor Window, Using an existing pack

Once finished, store textures for blender by selecting "File -> Export Texture Pack." Then, to store for use in Sonic Adventure 2, select "File -> Save As -> PAK." Feel free to use whatever names you like.

(Option 2) Creating a Custom Texture Pack

To create your own custom texture pack, select "File -> New -> PAK." This will let your texture pack use HD textures. Then, to add a texture, click on the "Add" button on the bottom left, which allows you to choose any png or jpg to act as a texture.

Texture Editor Window, Creating a new pack

Once finished, store textures for blender by selecting "File -> Export Texture Pack." Then, to store for use in Sonic Adventure 2, select "File -> Save As -> PAK." Feel free to use whatever names you like.

Creating / Editing a Level

Now that you have your textures prepared, you can begin creating a level by opening Blender. If you haven't already, install the SonicAdventureBlenderIO addon by selecting "Edit -> Preferences," then clicking "Add-ons" on the left. Then, click "install," and select the SonicAdventureBlenderIO ZIP file that you downloaded.

Blender, Addon info

Once the addon is installed, Blender can now import and export Sonic Adventure files. These files will start with either .sa1, .sa2, or .sa2b, and end with either mdl or lvl. "mdl" stands for model, and is used for characters, enemies, and objects. "lvl" stands for level, and stores information about level geometry, textures, and much more.

If you would like to create a new level from scratch, you can begin modeling a level as you would normally in blender. If you're downloading a map from online, you can import it into blender by selecting "File -> Import." If you'd like to update or use an existing Sonic Adventure map, you can import it into blender by selecting "File -> Import -> Sonic Adv. lvl (.*lvl)." Importing Sonic Adventure levels also automatically completes a few steps, making it an easy option.

If you would like to port over an existing map from another game, models-resource can be a great source for files. Maps will come in different formats you can import into Blender, and commonly come with texture packs. You can create a texture PAK following the "Creating a Custom Texture Pack" portion of this guide. Continue following the guide from here to import the Pak, and once that is done, you can assign textures using SonicAdventureBlenderIO's "Attempt convert materials" button in the "SAIO Tools" tab, in the "Material" section.

Note: Sonic Adventure and its modding capabilities are currently limited. Modern maps may not work in ways that you might expect, and depending on complexity, collision may not work correctly.

Scaling

Once you've created or imported a level, its time to scale it! Compared to Sonic Adventure 2, Modern tend to be either too big or too small- so to scale your level, you can create a model cube to help visualize how big Sonic is. So create a cube, and make the dimensions 3m long, 3m wide, and 5m high. Then, to scale your level, select all the meshes by pressing "A" on your keyboard, and scale by pressing "S" and moving your mouse.

Blender, Scaling your model

Optional: Sometimes, for a more accurate picture, people prefer importing Sonic's actual model into the level, which is ripped when you create a project in SA Tools. To do this, select "File -> Import -> Sonic Adv. model (.*mdl)," and import Sonic, who should be under "yourprojectfolder\figure\bin\sonicmdl\0.sa2mdl"

Note: To give you a better sense of scale, the roads in City Escape are about 40m wide, and with a full jump, Sonic can just barely get on top of a cube that's 25m high.

Texturing

To texture our level, we're going to use the "SAIO Scene" blender side menu. To open it up, press "N" on your keyboard, and click on the "SAIO Scene" tab. Then, to enable level tools, swap the scene type to "Landtable."

Optional: You can increase your blender render distance in the "View" tab, by changing "End" to a higher value. Helpful for big levels!

Blender, SAIO Scene tab

With the "SAIO Scene" Tab open, scroll down to the "Textures" tab, and there, you can import a texture pack by creating a new texture, then clicking the arrow on the bottom right, and selecting "Import texture pack." Once there, find and open the texture pack folder you created, and open "index.txt."

Blender, create texture

Blender, Import texture pack

Then, if everything worked, you should see that a list of textures was created. Note, textures will be set based on their ID in the texture pack index, rather than on the texture name- so it'll be important that you look back at the texture list to find the ID of the texture you want, or by looking back at the index.txt file in your texture pack.

To apply a texture to a part of your level, select the mesh(es) you would like to texture. Then, enter the Blender Material menu on the bottom right. If you don't have one already, create a material, then scroll down until you find the "SAIO Material Properties" section. From there, enable "Use texture," and set a texture by entering the index of the texture you would like. Then, to view it in blender, click the "Update properties" button.

Blender, Material properties section

If you still can't see textures, you may need to enable texture view, which can be done through the mini menu on the top right of your view.

Blender,  Render textures

Setting Collision

Now, to make your level work in game and let sonic move and jump on your level, you need to set collisions through the SA Blender IO addon. To do that, press "N" to access the sidebar, and once there, find and open the "SAIO Object" tab. Then, find the "Land Entry" section, open it, and then open the "Surface Attributes" subsection. Then, to set collision, enable "Visible" and "Solid."

Note: You can set collision for multiple objects by holding "Alt" when you enable surface attributes. If you are having trouble with selecting multiple meshes at a time, you can always use the mesh selector on the right side of the page, which makes selecting entire maps much easier.

Blender, Land Entry tab

NOTE IF YOU DOWNLOADED A MAP FROM ONLINE: Some online maps can come as one big mesh, but SA collision works better given separate pieces. So, you should split your map into more pieces. You can do this by selecting the meshes you would like to split, and going into the "edit" mode in blender, and pressing "P" on the keyboard. Then, in the menu, you can split your pieces by material, selection, or loose parts. Material split can work well if you've already assigned textures, but if not the other methods should work fine too. Then, make sure you re-set your meshes' collisions using the steps above. You can see if a given mesh has collision or not by checking the "LandEntry Properties" tab in the SA Tools addon, and opening either SA1 or SA2 Landtable flags.

Export Map

Once you're done creating, scaling, texturing, and setting collisions for your map, you're almost ready to export!

The last thing you need to do is make the geometry compatible with the SA2 engine. You can do this by selecting all meshes, pressing "ctrl-a" on your keyboard to open the "Apply" menu, and clicking "All transforms."

Blender, Apply menu

Then, with all meshes still selected, right click anywhere to open the "Object context" menu, and clicking "Set Origin -> Origin to Geometry."

Blender, Object context menu

Finally, you're ready to export! So, select "File -> Export -> SAIO Formats -> SA2B Land Table (.sa2blvl)." This level file will store all the meshes, texture indexes, and collisions of your level, but won't store things such as what texture pack the level will use, Sonic's start or end positions, as well as enemies. These will be added in a more advanced tutorial later, but just know through our mod you will be able to set a spawn location for sonic anyway.

Blender, Exporting your map

Making Your Level Playable

Now that all the hard work is done, its time to play! To add your level into the game, you have two options: either 1, code your own mod, which you can learn how to do here with code examples here, or two, you can use "My Level Mod," a tool I built specifically for this tutorial that makes importing levels into Sonic Adventure 2 easy and code-free.

To import your level into Sonic Adventure 2, make sure you download "My Level Mod" from GameBanana using the link in the 'requirements' section, and make sure that it's extracted and inside of your Sonic Adventure 2 'mods' folder (Should be: "C:\Program Files (x86)\Steam\steamapps\common\Sonic Adventure 2\mods\My Level Mod"). Then, all you need to do from there is simply drag and drop your sa2blvl and pak files into that mod folder, and run the game twice with the mod applied! The mod will automatically move the files into the correct spot for you. If you'd like to customize your level or add features, you can do so through the included 'level_options.ini' file.

My Level Mod in your mods folder

My Level Mod files

By default your level will replace City Escape, and to play your level, all you need to do is load up City Escape. If you'd like to learn more about what's possible with My Level Mod, you can check out the wiki here.

And with that, you're done! You can now play with your level in Sonic Adventure 2. If you chose to use My Level Mod, you can simply rename and edit it to be your own mod, and republish it to share with friends. If you would like to learn how to add rails, loops, enemies, and more, please see the more advanced tutorials. (Currently WIP)