Jump to content

Unity help please


Recommended Posts

As if the modeling end of this isn't difficult enough, now I've got a mesh in Unity and can't get it to write a KSP object.

I started with an empty game object. Then I added my mesh to that. Then I added the AUV file to the mesh in the hierarchy.

With the mesh selected I added a mesh renderer, a mesh collider, and parttools.

I can see the object in the window and the texture is correctly applied.

When I try to write the object in parttools I get the .mu file but no textures.

Also I keep seeing this error when I write the object:

NullReferenceException

KSPPartTools.PartToolsInspector.DrawMaterials ()

I'm sure this is a simple problem but it's another case of a minor issue holding things up for hours while I try to figure out what the problem is.

Are there any KSP/Unity tutorials of the same calibre as the Scott Manley videos? I've spent hours watching youtube videos and trying to follow along and still seem to be missing something.

Link to comment
Share on other sites

did you assign KSP shader to the object? is there a shader with a missing texture assignment in the hierarchy under the part tools object?

The error message indicates something related to shader or texture.

Link to comment
Share on other sites

Yes, I did assign the KSP shader and the object displays correcly in the Unity viewport.

I started with an empty hierarchy.

Then I added an empty game object to it.

Then I dragged the mesh onto the game object. The game object has the little arrow indicating the mesh is inside it so it seems like it should be parented properly.

At this point the untextured mesh shows up in the Unity viewport just as I would expect it to.

With the mesh selected in the heirarchy I start adding components to it using the inspector panel on the right side of the screen.

It already has a transform and animator component, so i add a mesh renderer, then a mesh collider, (and assing a mesh to it) then I add parttools.

When I saved the object from Wings 3D as a Wavefront object it wrote 3 files. The Mesh, an auv file that I presume is the material and UV setup, and the actual texture image.

In unity I drag the auv file onto the mesh in the heirarchy. Then I drag the texture image onto the auv in the heirarchy.

At this point my mesh in the viewport updates to show the texture properly applied.

I've gone through each item in the heirarchy and looked at every window in the inspector window and I don't see any blank entries and yet it still won't write the image with the object.

Now this is the part that really confuses me. If I've got it set up well enough for Unity to display the object for me, then why isn't it set up well enough to write the object for me?

Since you can change the image format that it outputs, doesn't that mean that Unity is going to write that image based on what's in it's memory? And it it can't find it in it's memory then how is it able to display the textured object for me?

I also looked at the tutorial by Some_Random_Guy as suggested above. But since he's not using textures it wasn't much help with this problem.

Everybody seems to agree that the Scott Manley tutorials on how to play KSP are some of the best, easiest to understand, videos available on the subject. Are there any tutorials of that quality avialable for this subject? I've read and watched lots of tutorials on this and still not managed to come away with enough information to make a simple KSP object.

Link to comment
Share on other sites

the only file you really need to import is the OBJ, which should have the UV information embedded, but even without UV information the export should still work just fine. on export to OBJ you get a 2nd file with .mtl extension, which is a lightwave material, you can discard that. and a texture of whatever format you specified when exporting

try this video see if it helps.

I exported a simple sphere with UVs generated in Wings3D. the Unity setup should look something like this image. Which version of Part Tools and Unity are you using? I can't replicate the error message following your steps.

ckhrgmP.jpg

Edited by nli2work
Link to comment
Share on other sites

Have you put a convex collider on a transform? unity doesn't like that and will only write a mu when you click export.

Why are you adding a mesh render as this is already done by default , most models being fully textured and uv'd before being imported. If you dont have animation you dont need the animator component,

Link to comment
Share on other sites

Nli2Work, As far as I can see my heirarchy looks the same as yours.

I looked at that video that you suggested. It's one of the many tutorials that I followed through and got nothing from.

He spends a lot of time talking about where to download stuff. If people are smart enough to make 3D models and use Unity doesn't it stand to reason that they could probably figure out a google search? For a first tutorial, why would he choose an animated part? Isn't a basic fuel tank confusing enough for the first lesson? And if he's really enough of an expert on Unity to be giving lessons then couldn't he struggle though using the default layout for 15 minutes to make it easier to follow?

But I'm just nitpicking details. The bottom line is that the video didn't help with my problem.

Anyways, thanks for the help guys. I've spent about 19 hours in the last 2 days struggling with trying to get an object from my brain to KSP. Clearly I'm just not smart enough to do it and have wasted enough time trying.

:^(

Link to comment
Share on other sites

sorry to hear that... it's the same video I used. Considering all the other videos are either 2 years out of date... or lasts couple hours. this is the best one I've seen.

Going from Wings3D to OBJ to Unity exporting .MU was more smooth than any other game asset I've ever made. if I could replicate your error, I might be able to help more.

Post the expanded details of your error by highlighting the error log in the console... should look something like this:

File error:

at (wrapper managed-to-native) UnityEngine.Mesh:get_vertexCount ()

at KSPPartTools.PartWriter.WriteMesh (System.IO.BinaryWriter bw, UnityEngine.Mesh mesh) [0x00000] in <filename unknown>:0

at KSPPartTools.PartWriter.WriteCollider (System.IO.BinaryWriter bw, UnityEngine.Transform t) [0x00000] in <filename unknown>:0

at KSPPartTools.PartWriter.WriteChild (System.IO.BinaryWriter bw, UnityEngine.Transform t) [0x00000] in <filename unknown>:0

at KSPPartTools.PartWriter.WriteChild (System.IO.BinaryWriter bw, UnityEngine.Transform t) [0x00000] in <filename unknown>:0

at KSPPartTools.PartWriter.Write (System.String modelName, System.String filePath, UnityEngine.Transform target, TextureFormat textureFormat) [0x00000] in <filename unknown>:0

UnityEngine.Debug:LogError(Object)

KSPPartTools.PartWriter:Write(String, String, Transform, TextureFormat)

KSPPartTools.PartToolsInspector:DrawWriterGUI()

KSPPartTools.PartToolsInspector:OnInspectorGUI()

PartToolsEditor:OnInspectorGUI() (at Assets/Editor/PartToolsEditor.cs:18)

UnityEditor.DockArea:OnGUI()

Edited by nli2work
Link to comment
Share on other sites

SpannerMonkey,

I'm positive you're right about it being some stupid simple little thing. I went through this same issue about 6 months ago last time I thought I was smart enough to make KSP objects. I spent days watching crappy videos. And more days fighting against the interface in various 3D programs.

In the end I managed to get Unity to spit out a few KSP objects, but it was a totally random thing. Sometimes it would work, sometimes it wouldn't. I never did figure out what the magic combonation was and even looking at my old unity projects I can't see what I'm doing different.

Finally I got so sick of it I gave up and stopped playing KSP for 4 months.

Part of the reason it bugs me so much is that I got into 3D a long time ago. Ever heard of Cad3D? It was my first 3D program on the Atari ST written by Tom Hudson who later went on to write 3D studio for Autodesk. Then I got an Amiga where there was lots of 3D software. I got pretty good at Sculpt 3D, Videoscape, Imagine, Real3D, Lightwave on the video toaster, and probably a few I've forgotten over the years.

But then I got out of that hobby and didn't touch a 3D program for a couple of decades. When I went to try it again last year I found out that not only had I forgotten most of what I knew, but that relearning it was very difficult/impossible. Apparently the part of my brain that used to be good at that sort of thing is no longer functioning.

The bad news is that this could happen to you guys one day since the only way to prevent old age is death. So enjoy your ability to do this while you've got it cause it might not last.

Anyways, as I said, thanks for all the advice but I think it's time to go back to playing Xbox games for a while. It's more rewarding.

Link to comment
Share on other sites

Hey who' re you calling young my 23 year old daughter may disagree. sinclair ZX 81 with a fuller keyboard wasnt up to much in the way of graphics!! I do this to stay young, beating myself with modding stick keeps brain active and problem solving is good for the soul if you believe in such stuff.

Send me a link by pm of your file and if you want i can walk you through it via teamviewer or just pm. dont you dare chicken out!!!

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...