Jump to content

Problem Exporting From Unity to KSP.


Recommended Posts

Hi. I was using the relevant tutorials and information ('stuck' to the top of the thread list) to help me learn how to export models from Unity. I followed them every step of the way, and yet I seem to be experiencing a problem not covered in any guide.

My export results. First, with the model file in the Hierarchy pane, I was unable to generate an MBM, but was able to generate a 4kb .mu file. Then I placed the model file (properly imported into Unity after properly exporting it from Blender as a .dae file) from within the hierarchy into the Part Tools GameObject, and that relationship allowed the MBM to be generated, but the now 45kb .mu file still doesn't seem to do anything. My .cfg file appears right and refers to the assets of the .mu and .mbm files but these do not load into the game and are not seen or referenced to within either the VAB or the SPH. I have a mod made by someone else properly located in my local game folders and it does load, so I doubt that the problem is due to placing my mod in the wrong folder.

Edit: whoops! I had this in my text and then deleted it. I'm using the latest versions of: Mac OS, Blender, Unity, KSP, Part Tools; cfg file using diff apps: TextWrangler, TextEdit, OpenOffice. /Edit.

Thanks in advance for any help on this!

PS -- for comparison, another thread in another part of the forum (where I also posted to). I think the Mod & Texture Discussion sub forum is a better place for my question.

http://forum.kerbalspaceprogram.com/showthread.php/34640-Problems-exporting-from-Unity

Edited by Dispatcher
Link to comment
Share on other sites

You don't need to export the model from Blender into any other format, Unity will load a .blend file just fine.

Also why are you using .mbm for your textures? Sure they load fast, but are rather big, and KSP is rather limited to how much it can load atm. Best choices for textures atm are .tga compressed or .png, though Im not sure if the .png Unity bug has been sorted yet.

Without more info though its kinda hard to pinpoint your issue. A screen shot of your Unity hierarchy and copy of your config will do wonders for other trying to help ya get this sorted. Also what versions of PartTools and Unity are ya running.

Link to comment
Share on other sites

Yes, Unity likes .blend files; even better than .dae files. I was merely following the tutorial directions. I am using .mbm as the export setting since it is default in the Part Tools exporter. I agree that .mbm files are large. It took my 512 x 512 texture and pumped it up to 1.1 mb.

I edited my post above because I dropped the info in the versions I am using. ^They are as current as can be.^

I'll put up a shot and the .cfg as time permits, by way of edit.

The screenshot(s combined):

9697852164_23e9300a09_z.jpg

The .cfg:

// Kerbal Space Program - Part CFG file

// its a fancy name

// --- General Parameters ---

name = model

module = FuelTank

author = Dispatcher

// --- Asset Parameters ---

// mesh = model.dae

mesh = model.mu

scale = 1

texture = model.mbm

// texture = model.png

specPower = 0.5

rimFalloff = 3

alphaCutoff = 0.5

// rescale factor = 1.25

// --- Node Definitions ---

node_stack_bottom = 0, -0.75, 0, 0, -1, 0, 2

node_stack_top = 0, 0.75, 0, 0, 1.0, 0, 1

//node_attach = 0.75, 0.75, 0, 0.5, 0.5, 0.5, 0

// --- FX Definitions ---

// ---Editor parameters ---

cost = 1350

category = Propulsion

subcategory = 0

title = a nice title

manufacturer = a nice one of those too

description = it will be decent, I think

// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision

attachRules = 1,1,1,1,1

// symmetry rules: 0=1x, 1=2x, 2=3x, 3=4x and so on...

// --- Standard part parameters ---

mass = 2.65

dragModelType = default

maximum_drag = 0.5

minimum_drag = 0

angularDrag = 0.25

crashTolerance = 50

breakingForce = 1024

breakingTorque = 512

maxTemp = 3000

heatConductivity = 3.6

heatDissipation = 0.014

// --- Special Part Parameters --- OR Specific Part Parameters ---

fuel = 215

oxidizer = 262

dryMass = 0.265

fullExplosionPotential = 10

emptyExplosionPotential = 0.9

Thanks again for any help!

Edited by Dispatcher
Follow up info.
Link to comment
Share on other sites

When you say it doesn't load into KSP, have you checked the alt + F12 debug menu? I've been using that to see which specific pieces of parts load (or not!). In the 'name' field of your .cfg have you changed that to whatever you call your object in Unity? For example, in your hierarchy screenshot it's still called 'model'. I *think* the name you call it in Unity and what you reference in the name field of your .cfg have to match.

EDIT: Screenshot here (This link actually works this time, I promise!) In my Hierarchy I've called my 'thing' HexBattery, but in part tools I kept the name field as model - I don't think I explained that very clearly before. It took me a while to realise they were two different things.

Edited by Milkshakefiend
Link to comment
Share on other sites

I followed your advice and matched the name field in the config file. Made no difference. Changed the file name to match the model file name also. No difference. Finally changed the cfg. file name to part.cfg just because it works for others. No difference. I've also tried with exported .dae file into Unity as well as the .blend file into Unity. No difference. I also followed your advice on the debug menu. Interestingly, while nothing shows up in the VAB parts area, the debug shows that my model and textures are in there. The config file does not show up. But since my problem is consistent, I am of the opinion that the game first looks for the .mu file, then the .cfg file. Since I think the .mu file is no good, it may then follow that .cfg file isn't seen due to that. I can't see anything wrong with my .cfg file. Here are images of mod icon files. The first image is of a mod by another author which loads and in fact appears in the game, in the VAB parts. The second is my mod.

9700393005_6a1fee0507_z.jpg

9703627038_afa519712d.jpg

The .cfg file icons differ because in this instance I used OpenOffice instead of TextWrangler to save that file. They are both text editors. Note that the .mu file icons differ. I don't think that should be the case. Mine is still about 45 kb in size. The other mod .mu file is about 418 kb in size. That is strange also because my model is more complex than the other model. I've tried different diffuse as well as bm shaders too, which is why you see an icon for a normal file for bump map as well as the other texture MBM file.

Perhaps my Part Tools didn't set up properly in KSP? At any rate, until a solution is found here, I'm thinking of doing the simplest model I can; a cube and a texture to test.

Edited by Dispatcher
Further testing.
Link to comment
Share on other sites

The log will tell you flat out if it "crashed" on the mu or cfg file, no need to guess.

That said, the cfg is the problem from what I see. Look at the existing files from Squad. If you're making a new tank you can pretty much copy an existing file and then just change the part name and tweak whatever other settings you want to fit your part. At the very least this should help you find where you've gone wrong thus far. Many tutorials contain some fairly dated information.

Also, you do not need to match cfg name to Unity name for the part itself. "name=something" just defines the name KSP will use internally, however, that name must be unique among all loaded parts or things get a little screwy. You do have to match the "mesh=something.mu" line to whatever you entered as the name for the exported model in Unity though, and if you add thrust transforms, seat pivots, intakes, or other things like that, their names must match in the config to what they are in Unity.

Link to comment
Share on other sites

I took your suggestion. Modifying an existing .cfg file is what I would have done if there were not a tutorial on said files. :-O It works like a charm now! Its clear from an actual vanilla part .cfg file that its a script; that's less clear in the tutorial. I need to adjust a few figures (the mass number is apparently dry mass, not total mass, for example) and now I can tweak the texture settings for looks. Another thing I did is generate the collision mesh only in Unity instead of in Blender (actually its the same mesh; just allows it to be collision as well as rendered). Its a simple mesh so no need for a separate collision mesh. I'll add a few things in gradually into the .cfg to modify behavior, but its off to a very good start now.

Thanks again!

Edited by Dispatcher
Added detail.
Link to comment
Share on other sites

No problem.

PS; As long as any mesh colliders you use have the "Convex" option checked they'll work. It is "better" to use a primitive if at all possible though. The game seems to handle primitives a lot more carefully than mesh, ie, a box collider will rarely get stuck in the ground while mesh colliders are notorious for doing so. The whole process is really just a lot of playing around to get to what works best for a given part, so you're on the right track there.

Link to comment
Share on other sites

Yes it will export at least one texture file in addition to the .mu, depending on the type of shader you chose in Unity. It will be either a .mbm, .png, or .tga file.

if you are only getting a .mu file then something is causing the export to error out. There is a way to open the unity program's log to see what it might be.

Usually, its a scene setup issue and the easiest way is to remove eveything from the "scene" section (including your Gameobject you added part tools to, the one where you set up the part name and texture type) and then add everything back in.

Stuff like animations and moving around objects as objects and parents too many times can bug out the scene, though those aren't the only causes.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...