Jump to content

Animation issues driving me up a wall.


Starwhip

Recommended Posts

Heyo, there. Continuing with my modding misadventures, I have found that Unity hates me more than ever. How does one get an animation from Blender into Unity, and then have Unity export it to the game? And in the CFG file, how do you get the part to run the animation?

I've successfully imported parts into KSP, so that's not a problem. I've also had them run SCIENCE experiments. ATM, animations are my only issue.

Link to comment
Share on other sites

I see,

Heres how you "fix" it (notice the ").

Read all of it!

Animate:

In blender do a normal animation after you have created your part. So set max keyframes to 100 then go to keyframe 0. At kf 0 right click the "part" you are moving or rotating then with it selected hit "i" on your keyboard. A menu pops up saying add keyfram then find LotRotScale. Then move the green time cursor around the timeline, You'll see on frame 0 there is a yellow mark. Good! Now go to keyframe 50. At 50 rotate scale and move your part around. This would be the "Activate" animation. Then once thats done do the same thing(Hit "i" add keyframe REMEMBER TO BE AT FRAME 50 and hit LocRotScale). Now once thats done go to frame 0 and try to move around to timeline so the animation works. If your part doesn't move anywhere re-read my instructions, I animate(some) in blender and this is the way to do it. Got it working? Great! Now the deactivate, Go to frame 100(last frame you can set it to the last setting the "End:" value on the timeline from 250 to 100. At frame 100 make the part go back where it was at frame 0.

IMPORTANT!!! I BELIEVE YOU HAVE TO MOVE YOUR NODE_COLLIDER TOO! I am not too sure but if you want proper collision then I think you do, For that, its just the same way

Export:

It's time for moving to Unity,For the next part select all parts of your "part", The collider and everything. Go to FILE > EXPORT > Autodesk(.fbx) Export it to a new folder in your Desktop. In export settings(bottom left) make sure to have "Selected Objects" checked. Don't mess with anything else. Get the folder that you exported your fbx in, Open it. Make a new folder in it named TestAniPart, Leave the folder be. So heres the recap. You should have a folder named anything with a .fbx file in it and a folder in the same directory named TestAniPart. Alright now, The fun stuff!

Import to Unity:

Open a new project in Unity, I have one already for KSP but you can use pretty much any. Make sure nothing except Main Camera is in the Hierarchy. Also go install KSP Part Tools .23. Do that then continue. Now you have part tools, In assets you see Editor, Lib and Shaders. Make 3 folders named, Models, Textures and Processed Models. All in Assets. You should have a PNG file(or what ever you use) as your models UV map. Put that in textures. Now open the Models folder, Make a new folder named AnimatePart. Open that. Now open the folder you had on your desktop, Drop the fbx file in Assets > Models > AnimatePart (so <-- that folder) Now you see it generated a materials folder with materials. I made a test part with a simple animation so I didn't have materials. Now next step.

Setting it up in Unity:

This is the main step! Click on your model in AnimatePart, You get a list of settings in the inspector. Go to the Model section if it isn't there. Set scale factory to 1 and Checkmark Generate Colliders. Set normals to calculate. Now go to Rig. Set Animation type to Legacy, then your done there go to Animations. Where it says clips hit the plus button 2 times, so 2 clips are added. The "Default Take" can have the whole animation, Rename "Default Take0" to Extend(?) or what ever you are doing. For "Default Take1" rename that to Retract(?). Go to Extend, Set start to 0 and end to 50, Set retract to Start 51 and end 100(or 99 if Unity won't allow you to) Apply all settings.

KSP Import:

In Unity create an empty GameObject. With all settings saved move your part from the AnimatePart in Unity into that Game object. Hit all the arrows to open it, If you accidently exported the Lamp and Camera no worries! Just delete them. click on the part and check if the animations are set up. Now you have the material when you have the part selected( I used the cube you start with so my is named cube so select it) When its selected make sure it has material Mesh collider and renderer. At mesh collider check "Convex". Now at Material(for me I still have the Cube selected, If you have multiply parts you have to do this) Click shader, Then hit KSP then diffuse. Then there is a box that says None (texture), Put your .png UV image file there, Don't have one? Leave it blank then. Now select the game object, Hit add component > KSP > Part Tools. So you just added a Part Tools componant to the game object NOT THE CUBE OR THE PART, Now set Model name to "model", File URL? Hit set then go to the TestAniPart folder, Set it there. Texture format? Use mbm or png. Then hit "write"! If it doesn't work then set the File URL(the output) to that folder processed models in your assets. Make sure that model.mu is in TestAniPart. Now put your .png or .mbm in there too! Next thing, Go to the ksp directory(E:\Steam\SteamApps\common\Kerbal Space Program\GameData\Squad\Parts\Utility\LandingLeg For me) Go to Gamedata > Squad > Parts >Utility > Landingleg. Yes landing leg! Open the CFG file in notepad then close out of the directory. Open TestAniPart. Right click and hit new then new text document. When naming, Delete the whole name then put part.cfg so it changes it from .txt to .cfg. Doesn't change? Instead open notepad and then hit Save As and go to TestAniPart as set the save setting to All Files, then do part.cfg!

CFG:

Copy all the data from the landing leg cfg to your cfg, Edit it to your liking and make sure to change name = (at top) to something different so it works. Now go to the bottom where you see MODULE {name = modulelandingleg} blah blah yeah. Put this instead:

MODULE

{

name = ModuleAnimateGeneric //Dont touch

animationName = Extend // The animation name

startEventGUIName = Extend //Pretty Self explanatory

endEventGUIName = Retract

}

MODULE

{

name = ModuleAnimateGeneric

animationName =Retract //Rename this to the retract animation name

startEventGUIName = Retract

endEventGUIName = Extend //Flip these. In theory this should work!

}

KEEP MODULE NAME = TARGETPART

Now with everything set up, Put TestAniPart in Gamedata > myparts > Parts.

Run KSP and boom!

I really hope this help! Spent the last hour typing this so my hands hurt!

Rep would be nice! :D

Sincerely, SRG

P.S. Hop on esper.net channel #kspmodders They give some nice help :D

Link to comment
Share on other sites

  • 2 weeks later...

MODULE

{

name = ModuleAnimateGeneric

animationName =Retract //Rename this to the retract animation name

startEventGUIName = Extend

endEventGUIName = Retract

animSwitch = True //will set gui button name to "Retract" if part is Extended and play Extend animation in reverse when "Retract" is clicked

}

you can use the "animSwitch = True" line instead of using a 2nd module to reverse the animation.

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