Tutorial:Making an asset from start to finish

From Kerbal Space Program Wiki
Jump to: navigation, search

Currently in Progress

Template:Empty section

Creating a game ready asset

You can use this at any time during your asset creation to refer to and to troubleshoot with. This is a step by step guide to creating the cool mods you see in game. This tutorial is not for the faint of heart. Proceed at your own discretion.


  • Length: Varies by user
  • Difficulty: Intermediate
  • For version: Every version


Step 1 - Choosing the program

Despite popular belief, this is not an important step. Any old program will work. The main ones:

3ds Max (Good to go)

Maya (Good to go)

Blender (Good to go)

Wings 3D (Cannot import .DAE models)

Sketchup (Needs a .DAE importer/exporter)

Cinema4D (Doesn't auto unwrap by powers of 2; exports do not function)

Step 2 - Understanding Folder Design

By convention, mods now create their own directory inside the GameData folder. This can be called anything you like, though steer clear of spaces and special characters just to be on the safe side

Things to keep in mind:

You may have seen reference to models being loaded into KSP as .dae. This changed a long time ago with the release of the PartTools scripts for Unity. The process now is to export the model from your 3D program to a format that Unity understands (DAE, FBX and .blend are commonly used), set things up in Unity (which will be explained in detail later), then, using PartTools, export the compiled .mu model file that KSP can load. PartTools will work with later Unity version, but 4.2.2 is the correct version to use. Later versions do not support certain features (such as the animation type that KSP uses), so you're in for a world of pain if you don't stick to Unity 4.2.2. There appears to be information somewhere that Unity 4.6 should be used for KSP modding. This is incorrect.

Step 3 - Creating The Model

This part is completely up to the user. Anything that you can dream up, with feasibility in the Kerbal world is acceptable. Everyone will make different assets depending on their program fluency, desires, and expectations. Some things to keep in your mind while creating an asset(s);

  • Triscount
  • Unwrapping
  • Textures
  • Collision mesh.

Tris are what every model is made out of in any 3D game to date. No matter what program you use a game engine will split your model into the smallest geometric shape; a triangle. This should be your unit of measure when judging the complexity of a model. The vanilla, or stock parts, default pieces issued with the game are the best judge for what the KSP is built for, and the mod packs on the forums are the best judge for what the limit is.

The triscount for most of the stock pieces are around 300 tris for small pieces like the TT-38K Radial Decoupler, and 2000 tris for pieces like the LV-T30 Liquid Fuel Engine and a general 1000 tris count for the boosters, fuel tanks, and pods. When assessing your tris count it's necessarily to keep in mind you want an optimized number. You want to have the lowest tricount possible, without taking away from the integrity of the model's silhouette. When modeling one can get lost in adding detail, and whilst finishing up its important to give your model a twice over. Don't feel bad if you aren't quite satisfied with your model: remember that what gives a soul to the model really is the texture.

Step 4 - Unwrapping and texturing Your Asset

This step varies from program to program. Refer to your program's documentation to make sure. Essentially, this part binds the faces of your model to a specific spot in your texture file. There really isn't much to be said about this; experience is what makes good unwraps. Once you have distributed the faces around the UV plan, make sure to make a render/snapshot of the UV position, saving the resulting image in a PNG file that has a format in powers of two (128x128 or 256x256 is ideal, 512x512 for high-detail meshes. 1024x1024 is beginning to be a bit large.)

Open your UV render in your image editing program of choice (I personally recommend Gimp or Photoshop, but MSPaint is fine too). Get artistic, following the lines of the UV map so it actually shows on your model. Save it the same format, but try not overwriting the UV - it's always handy to have. Again, here, there is only experience which will make you good - although a quick tip: premade textures are quite handy to have (such as metal textures and such) if you're feeling lazy/unambitious/unskilled. Trial and error is quite often used here. You may use the PartLab, available on the download page, to check the progress/if it's right.

Step 5 - Setting up Unity

Download and install Unity 4.2.2 here and install it. When you first run unity, it will ask you to create a new project. Do so, but do not select any of the default assets or packages to import. You will be presented with a screen with four panels: Hierarchy on the left, Scene in the middle, Inspector on the right, and Project at the bottom. It's fine to delete the camera from the hierarchy panel on the left; we don't need it.

Download PartTools here. Installation is simple: unzip it into the "Assets" folder inside the Unity project folder you just created. Contrary to popular believe, there is no need to install PartTools .20 first. The confusion appears to stem from .20 being supplied as a .unitypackage, which is just a special type of self unzipping package Unity uses. .23 is a a plain old zip, so it requires manually unzipping into the Assets folder. Once Unity has processed the script, a new Tools option will be available in the top menu. A little window called PartTools should also appear, with a button called "Set Data Dir". Click on this, browse to and select the GameData directory inside the KSP install you're using.

That's it: you're ready to import some models

Step 6 - Adding Your Model Into Unity

Let's take a minute to talk about workflow: Any models that you export from your 3D program in a format that Unity understands will appear immediately in the folder structure in the Project window in Unity. Good practice is to create a folder within the assets folder for each part you're working on. You can place your mesh, materials and textures in here for each part to keep the organised. Go ahead and do that, then export your model from your 3D program straight into that folder. When you see it appear, drag it into the inspector window and it will pop up in the Scene window. Don't worry if it doesn't, just select in the hierarchy and press the F key to focus on the object. It may appear untextured; don't worry about that for the moment.

Step 7 - Creating Materials

Unity uses materials to define how visible effects appear; these are often referred to as shaders. Squad has set up some custom shaders for KSP to use, and it's wise to use them or unexpected things happen. Right click somewhere inside the folder for your part and select Create > Material. Give it a sensible name. In the inspector window, you'll see a little pulldown menu called 'Shader'. Click on it, and select the appropriate shader from the KSP menu option. For your first part, just choose Diffuse, which applies a plain texture with no bump or specualar map. If you've already added the texture for your part into the parts folder within Assets, click the Select button in the texture slot in the shader, and choose your texture. Now you need to apply your material to your model. You can click and drag it onto the various components of your model in the scene window, at which point the texture will show up on the model.

Step 8 - Creating The Collision Mesh

There are many more options for creating collision obects than using a mesh. Unity supports box, capsule and sphere as well as mesh collider. The least expensive of these (for the physics engine) is sphere, followed by capsule, followed by box. Mesh is expensive. And becomes more expensive the more faces the mesh collider has. The physics engine in KSP is hard worked already. Let's not stress it any more than we have to.

So let's say you've made a fuel tank. Sadly, box, sphere or capsule don't really suit its shape. So you thought ahead and made a mesh for the collider, didn't you? For a fuel tank, it's a plain, ~12 sided cylinder of a size which encapsulates your part. To make it into a mesh collider, select it, click the "Add Component" button in the inspector, and choose Physics > Mesh collider. You MUST click the convex button. Collisions meshes may not be concave if you want them to work correctly. You'll now find that the object is highlighted with green lines, but it's still visible, which you don't want. Find the "Mesh Renderer" component in the inspector, click the little gear on the right of its heading bar and select "Remove Component". Do not remove the "Mesh Filter" component! if you do so, your part will not export when you come to it.

If you decided you can make do with primitive colliders, the easiest way is choose GameObject > Create Empty from the top menu, and add the sphere, box or capsule collider using the Add Component menu. Scale and place it appropriately.

Step 9 - Adding PartTools

So you've got your part into Unity looking all pretty with its texture and collision objects. How do we get this thing into KSP? From the top menu, choose GameObject > place with within the model where you want to centre of mass. Call it something sensible like "Root". We're going to use this as a top-level object for your part. CoM, attach nodes etc. all use the position of this object as a refenence for thier position. In the hierarchy panel, drag the top level object (or objects) of your model onto the empty GameObject you just created. In Inpsector, click Add Component > KSP > PartTools. Once the component is added, put something in the name box, choose the directory to export your part into, then select which format to export your texture to. DDS is not supported, so you'll have to convert after. Don't worry that the extension won't match what the model was exported with; as long as the name before the file extentsion is the same, it doesn't matter.

If you're struggling there's also a video tutorial

Step 10 - Exporting Your Asset

Click the big "Write button". This may take a few seconds as textures are converted. Check the "Console" tab in unity next to Project. Typically, two entries will appear in the log that will look like this:

C:/KSPDev/GameData\KerbalFoundries/Assets/IVA UnityEngine.Debug:Log(Object) KSPPartTools.PartWriter:Write(String, String, Transform, TextureFormat)

C:/KSPDev/GameData\KerbalFoundries/Assets/IVA\RollcageIVA.mu written.

If you have any red warnings, take care to look at those. PartTools will leave half written .mu files as they are if the export fails for any reason, which KSP then won't load. Remember to check that the export was actually successful! You should find that the .mu you name, plus any textures assigned have been exported to the folder you selected on the previous step.

Step 11 - Preliminary configuration

This will depends largely on what you want your part to be. Copying a stock config is usually useful. Key fields are annotated below:

	name = fuelTankSmallFlat //This MUST be unique!!!
	module = Part
	author = Squad
	mesh = model.mu	//This is case sensitive, and assumed the config is in the same folder as your .mu
	rescaleFactor = 1.0 // default is 1.25 Use at your discretion.
	node_stack_top = 0.0, 0.3125, 0.0, 0.0, 1.0, 0.0, 1 //this defines a stack node. See Note below.
	node_stack_bottom = 0.0, -0.3125, 0.0, 0.0, -1.0, 0.0, 1
	node_attach = 0.5, 0.0, 0.0, 1.0, 0.0, 0.0 //this is the surface attachment node.
	TechRequired = basicRocketry //defined the tech node
	entryCost = 1200
	cost = 150
	category = FuelTank //Only certain categories are pre-defined. Be careful to choose one of them.
	subcategory = 0
	title = FL-T100 Fuel Tank //This is what appears in the editor tool tip box
	manufacturer = Jebediah Kerman's Junkyard and Spacecraft Parts Co
	description = The T100 is a miniature fuel tank made to be even more adorable than its bigger brother, the T200. Handle stoically and with care.
	attachRules = 1,1,1,1,0 // attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
	mass = 0.0625
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.2
	angularDrag = 2
	crashTolerance = 6
	maxTemp = 2000
	breakingForce = 50 //how much force before the joint breaks
	breakingTorque = 50 //how much twisting before the joint breaks
	bulkheadProfiles = size1, srf //part size for sorting in the editor. Does not affect part physics.


Step 12 - The Last Checkup and the preparation

Now, in theory, you should have your full part. However, don't get ahead of yourself - you'll only attract shrapnel if you jump right in. Be sure to test your part thoroughly (an easy way to do this is to have a clean install dedicated to testing new parts to make sure it works before sending it into your main install). Tweak it as you want it to feel. Once you're satisfied, make sure to take a few screenshots of what your part(s) look like. Upload your pictures and part(s) somewhere (I wouldn't recommend dropbox - too high traffic might get your public folder disabled for sharing), save the links. Once all of this is done, you may proceed to...

Step 13 - The Release

Using the links you have previously acquired, make a thread in the Projects and Release section of the KSP forums. Post it, wait, and bask in your newfound success!

Step 14 - The updates

This step is entirely optional. You may choose to continue working on your part, using the criticism of your peers as inspiration.