Jump to content

Importing animations


Recommended Posts

I'm stumped on this one and hoping someone can shed some light on this. First of all, let me start by saying that my Unity knowledge is limited to just importing models, setting up materials and exporting to Kerbal. This is the first time that I'm trying something a bit more advanced so maybe I'm missing a step. So here's my issue:

I create a model with an animation. I import it into Unity via FBX and set up the animation to Legacy. Give it a name, set up part tools, add materials, colliders and export. So far it all works.

But then, when I start the game, it just hangs loading the part. Here's the error log:

[LOG 22:51:42.801] DragCubeSystem: Creating drag cubes for part 'im.test'
[EXC 22:51:42.858] NullReferenceException: Object reference not set to an instance of an object
	ModuleDeployableSolarPanel.AssumeDragCubePosition (System.String name)
	DragCubeSystem+<RenderDragCubes>c__IteratorC.MoveNext ()
[EXC 22:52:30.082] InvalidOperationException: Steamworks is not initialized.
	Steamworks.InteropHelp.TestIfAvailableClient ()
	Steamworks.SteamController.Shutdown ()
	SteamController.KSPSteamController.OnDestroy ()

I tried this with Unity 5.3, 5.2 and with 4.2 as well. All with the same result. I'm trying this with the 1.1 Pre Release of Kerbal.

Any help is appreciated. If there's any more info needed, let me know and I'll post ASAP.

Edited by v1per
Link to comment
Share on other sites

looks like the MU couldn't load, you'll have to find the relevant error messages, either in KSP.log or in Unity Console. Since it's animation related, I'd start checking in Unity Console. CTRL-SHIFT-C in Unity, then export your model and see if any error messages come up. If not, load up KSP and search KSP.log for any errors related to your MU file.

this thread may help if you find error messages

 

Link to comment
Share on other sites

The only error I can find is the one that I already posted. Unity is compiling the model just fine without errors on console. The animation even works inside Unity if I hit play and click on the part.

I thought maybe it was something to do with the bones that I used to animate the part, but I tried exporting a simple cube with an animation and I hit the same issue with it.

Link to comment
Share on other sites

there's an error message if KSP hangs loading your part, you just haven't looked in the right place. 

if you're attempting to load "im.test" as the part model I expect that would be prolematic. all KSP models are *.MU. your error message in OP is NullRef when attempting to create dragCube for "im.test". that means whatever "im.test" is, it isn't in memory when KSP is generating dragCubes. The relevant error is likely earlier in the load process when KSP is loading the actual models.

Edited by nli2work
Link to comment
Share on other sites

As I understand it, im.test is the name of the dragcube object that KSP creates when loading the part. The name of the actual file is test.mu.

And if there's somewhere else that I could look for an error, I'm all ears. I lost the better part of a day trying to find what the issue is. All I know so far is that if I export an object without animation, everything works fine. The moment I add some kind of animation, the game hangs on load. Maybe it's 3ds max that is exporting it with something that's not supposed to, but I doubt it.

Link to comment
Share on other sites

you have to post your logs then. I have no idea where and how you're looking. The error message in the OP simply means "im.test" isn't in memory when KSP is attempting to generate dragCube for that part. Delete KSP.log in the root, then run KSP till it hangs. ALT-F4, then search KSP.log for test.mu; there should be at least 4~6 entries. one of them would likely contain the error message you need to figure out what's wrong.

Edited by nli2work
Link to comment
Share on other sites

Ok. The issue isn't related to animation then, not directly at any rate. all the assets loaded fine, there's nothing wrong with the animation or part export.  

look in PartsDatabase.cfg, and search for your solarpanel part and see what turns up... probably something not quite right. All the stock retractable solar panels have 3 dragCubes. Copy one of those (most similar to your solarpanel) and paste it into your part's config see if that will get it to load. If it does, then you have to either redesign the animation, the way the panel folds up, so it works with the dragCube generation process; or tweak an existing dragCube set to fit your solar panel part.

can you show how the part animates? is it using skinned mesh? 
 

Edited by nli2work
Link to comment
Share on other sites

On 4/13/2016 at 7:07 PM, v1per said:

But then, when I start the game, it just hangs loading the part. Here's the error log:


[LOG 22:51:42.801] DragCubeSystem: Creating drag cubes for part 'im.test'
[EXC 22:51:42.858] NullReferenceException: Object reference not set to an instance of an object
	ModuleDeployableSolarPanel.AssumeDragCubePosition (System.String name)
	DragCubeSystem+<RenderDragCubes>c__IteratorC.MoveNext ()

 

ModuleDeployableSolarPanel.animationName isn't among the AnimationStates the part model's first Animation component has. Make sure that the animationName defined in your part's ConfigNode for the solar panel module actually exists in the Animation

Edited by xEvilReeperx
Realized portion was incorrect; no NRE thrown if part model does not have Animation component
Link to comment
Share on other sites

So, I tried adding the drag cube definitions suggested. It all worked after that. So it's definitely something in the animation that makes the game not able to produce the drag cube definitions. Once I added the drag cubes myself, the animation played perfectly in game. And no, I did not use skinning. Only connected parts to bones to make it all easier to animate.

Here's the animation: Solar Panel animation

And here's a screenshot in Unity: Screenshot

Part CFG:

PART
{
	name = asimov_retractablesolarpanel
	module = Part
	author = Viper
	mesh = retractableSolarPanel.mu
	rescaleFactor = 1
	node_attach = 0.0, 0.0, 0.0, 1.0, 0.0, 0.0
	TechRequired = advElectrics
	entryCost = 3800
	cost = 380
	category = Utility
	subcategory = 0
	title = Retractable Solar Panel
	manufacturer = Incredible Machines
	description = The OX-4 is similar in design to the SP series solar panels, but without the heavy casing.  Includes passive radiators on the reverse side for better heat dissipation. WARNING: Not retractable once deployed!
	attachRules = 0,1,0,0,1
	mass = 0.0175
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.2
	angularDrag = 1
	crashTolerance = 8
	maxTemp = 1200 // = 3200
	bulkheadProfiles = srf
	thermalMassModifier = 2.0
	emissiveConstant = 0.95
	heatConductivity = 0.04 // 1/3 the default
	tags = array charge deploy e/c elect energ extend generat (light photo power solar sun track unfold volt watt	
	MODULE
	{
		name = ModuleDeployableSolarPanel
		animationName = expand
		resourceName = ElectricCharge
		chargeRate = 1.64
		retractable = false
	}
	DRAG_CUBE
	{
		cube = RETRACTED, 0.1949,0.9924,0.2973, 0.1949,0.957,0.2458, 0.05804,0.8956,0.6314, 0.05805,0.8728,0.5185, 0.0635,0.9513,0.433, 0.0635,0.952,0.4847, -0.03427,-0.1231,-1.851E-05, 0.2383,0.5386,0.4
		cube = EXTENDED_A, 0.07375,0.9495,2.717, 0.07375,0.7225,2.651, 1.017,0.9919,0.2336, 1.017,0.9895,0.2723, 0.07369,0.9554,0.2871, 0.07061,0.9542,0.2871, -1.235,0,5.469E-06, 2.64,0.2924,0.4
		cube = EXTENDED_B, 0.07172,0.9664,2.706, 0.07172,0.7061,2.651, 0.06274,0.9534,0.2918, 0.06274,0.9534,0.2918, 1.028,0.9916,0.2324, 1.025,0.988,0.2121, -1.235,0.02947,-7.451E-09, 2.64,0.4,0.2326
	}
}

 

Edited by v1per
Adding part config
Link to comment
Share on other sites

I asked about skinned mesh because I think RoverDude had a similar problem involve dragCubes when making the new depolyable heatshield. Nothing in your part's animation seems problematic, very stock like. very strange... everything seems to add up. At least the part's working and there's a workaround. :/

Edited by nli2work
Link to comment
Share on other sites

Yeah, I'm going to try a few more things here, but if it keeps giving me trouble, I'll just study up on the drag cubes definitions, make my own and move on to another part. I've basically spent a week on this, and there are more things I want to do for my mod before 1.1 releases.

Link to comment
Share on other sites

I think I figured out what it was... actually not directly related to animation nor dragCubes at all.

DeployableSolarPanel requires a gameobject for pivotName value, default name is sunPivot. All stock solar panels use the default name so the setting isn't specified in the part configs. Apparently this object is required to generate proper dragCube for the solar panel parts. 

If you add an object to the part in Unity and name it sunPivot, everything loads in KSP fine without explicit dragCube definition in the part config.
If you rename one of your exisitng objects (other than the object hosting Animation component) in the part to sunPivot, everything loads in KSP fine without explicit dragCube definition in the part config.
if you don't have an object called sunPivot, KSP will hang when loading the part, same exact error as in the OP.
if you don't have an object called sunPivot, but have dragCube definition in the part config, part will load fine.
if you have a sunPivot initially and load the game once, then remove sunPivot, game will load fine since proper dragCube definition is stored in PartDatabase already

you can assign a specific object using pivotName =; but it cannot be the same object hosting the Animation component. the generated dragCube differs depending on what you use as sunPivot object. 

lesson learned, deployable solar panels are complex creatures.

Edited by nli2work
Link to comment
Share on other sites

It seems you are correct. After adding the sunPivot object everything works without drag cubes being added in manually. Since this was the first time doing a solar panel, I thought I'd do things in parts. I figured I'd import the animation first and see it working before bothering to actually set up all the solar panel parts needed. Silly me. Sorry for bothering you guys. At least now we know that if things aren't set up exactly, it all goes to crap.

I might do an actual tutorial on all this later. This is nothing but trivial. I'm now trying to set up the sun tracking and that is a nightmare in of it self.

Edited by v1per
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...