MrHappyFace

[1.1.3] Kerbal Animation Suite

Recommended Posts

A while ago, I attempted to create a tool to animate kerbals, for things like cinematics and other plugins, but I ran into a completely breaking issue, that only occurred on some computers, and I couldn't figure out how to fix it. Thankfully, my computer began encountering this error thanks to the Windows 10 update, and I was (hopefully) able to fix it.

So here it is, Kerbal Animation Suite v1.1.3.2. It runs with KSP 1.0.4, and allows the creation of animations for kerbals on EVA.

WB451PQ.jpg

These gifs demonstrates this mod:

http://gfycat.com/DifficultDeterminedGalapagospenguin

http://gfycat.com/HilariousNarrowFlies

http://gfycat.com/PettyMintyIrishdraughthorse

I posted these gifs on reddit a while back, if you recongnized them. The animation files for them are all included in the download.

This mod has 2 components: the animator, and the API.

Animator:

The animator is the main tool, which allows you to create, edit, play, and export .anim files, which can be used by your own plugins.

Getting started with the animator

  1. Install this mod
  2. Launch a ship, or go to one you've already landed somewhere.
  3. Go on EVA. The animation tool will only work if the kerbal is standing on dry ground.
  4. Click the kerbal face looking button in the App Launcher

You will see 4 windows pop up.

  1. The Bone Hierarchy window, which is where you select the bones to manipulate.
  2. The Manipulation window, which is where you manipulate the selected bone.
  3. The Animation window. This is the most important window, it's where you Load animation files, create them, and manage the timeline of the loaded animation.
  4. A little window in the top right corner which allows you to hide any of the other 3 windows

You will also see, if you right click on the kerbal while you're NOT in the animation screen, there are some new right click actions. You can play any animation anywhere in the GameData folder, and you can reload the animations (Reload Animations) if you want to test animations you've just made. You can also use the 1-9 keys to play animations without the rightclick menu. There are 4 animations included with the download in the Presets folder.

Source Code: https://github.com/HappyFaceIndustries/KerbalAnimationSuite

Download: https://github.com/HappyFaceIndustries/KerbalAnimationSuite/releases/latest

Latest Version: v1.2.0.0

License: GPL v3.0 [full text]. Code in the API subdirectory is not restricted by this licence, and is in the public domain.

 

API:

The API is a file that mod developers can include in their plugins that handles the loading and playing of animation files.

Because it is not a seperate dll, there's no need to include the animator with your download when releasing a mod that uses these animations.

You do, however, need to include a copy of animation_hierarchy.dat with your mod, which can be found in GameData/KerbalAnimationSuite/Config

You can see the API here: https://github.com/HappyFaceIndustries/KerbalAnimationSuite/tree/master/KerbalAnimationSuite/API

The API has 2 classes.

KerbalEVAUtility class

public static void AddPartModule(string moduleName)

public static List<KFSMState> GetEVAStates(KerbalEVA eva)

public static List<KFSMState> GetEVAStates(KerbalEVA eva, List<KFSMState> states)

public static void RunEvent(this KerbalEVA eva, string name)

public static void RunEvent(this KerbalFSM fsm, string name)

The first method, AddPartModule, is the most important. You can use it to add your own part module to the kerbalEVA and kerbalEVAfemale parts, which aren't supported by ModuleManager, so using a plugin is the only way. This is the reccommended way to handle animations, but if you're feeling adventurous (or stupid) then you can use some other method.

The other methods are methods to manipulate the Kerbal's Finite State Machine (KerbalFSM). The KerbalFSM is the engine kerbal's use to handle animations, like walking, swimming, etc. I highly reccomend you research the concept of Finite State Machines if you haven't already, and want to use this.

KerbalAnimationClip class

public KerbalAnimationClip(string url, bool fullPath = false)

public void Initialize(Transform transform, Animation animation)

public string Name
{ get; }

public int Layer
{ get; }

public float Duration
{ get; }

public UnityEngine.AnimationClip Clip
{ get; }

Basically, you use the constructor to create the clip object, then load the animation by putting in a path relative to the GameData folder (example: Squad/Animations/bleh.anim), a ConfigNode object, or a full path if you so choose.

You can optionally set more values in the Clip property, such as the frame rate, wrap mode, etc.

All of the properties are set in the .anim when you create the animation using the animator, but you can edit those values in the Unity animation system later, after you call Initialize.

Then, you use Initialize to add the animation to the kerbal's transform/animation components. If you're use a part module added to the kerbalEVA and kerbalEVAfemale parts using KerbalEVAUtility.AddPartModule, then just use transform and GetComponent<Animation>() as arguments.

The rest of the code will be done with Unity's AnimationClip, Animation and AnimationState classes. You can see the documentation for those here:

http://docs.unity3d.com/ScriptReference/Animation.html

http://docs.unity3d.com/ScriptReference/AnimationClip.html

http://docs.unity3d.com/ScriptReference/AnimationState.html

So far, 1 mod has been made that uses the API:

Special thanks to 

Edited by MrHappyFace
1.2.0.0 and 1.1.3

Share this post


Link to post
Share on other sites

*starts throwing Funds at you*

*clutches the Kerbal Animation Suite closely and covetously*

Share this post


Link to post
Share on other sites

Have you considered writing a tool that exports the kerbal transform hierarchy into something like Blender instead of painstakingly doing animations by hand? That was my first thought when I saw that you'd already gotten the import-into-FSM part working

Share this post


Link to post
Share on other sites

Thank goodness, I was honestly starting to believe I had just imagined seeing this a while ago, conjured up by my brain as wishful thinking. Great to see it's really a thing

Share this post


Link to post
Share on other sites

This is so cool. I can see many cinematics making use. did you ever see the Queen parody Darren9 produced? It would be even more awesome with custom animated Kerbals...

Share this post


Link to post
Share on other sites

PVstO54.png

Okay, now how do I take a frame?

I know there is a button for it, but it doesn't seem to function.

Would it be possible for someone to make a list of what buttons both on-screen and on the keyboard/numpad do what? That would be brilliant.

Share this post


Link to post
Share on other sites

Could you send me a copy of your ouput_log.txt and animation_hierarchy.dat?

The output_log.txt file is found in KSPRootFolder/KSP_Data and the animation_hierarchy.dat file is in GameData/KerbalAnimationSuite/Config

Edit: wait, I found the issue, it's a typo in the code. Try this build: https://github.com/HappyFaceIndustries/KerbalAnimationSuite/releases/tag/1.0.1.2

Edited by MrHappyFace

Share this post


Link to post
Share on other sites

I second blender exporting of kerbals, it would make rendering them so much easier too. :sticktongue:

Share this post


Link to post
Share on other sites
Have you considered writing a tool that exports the kerbal transform hierarchy into something like Blender instead of painstakingly doing animations by hand? That was my first thought when I saw that you'd already gotten the import-into-FSM part working
I second blender exporting of kerbals, it would make rendering them so much easier too. :sticktongue:

Exporting the kerbal model and textures might be considered stealing, and is definitely against the EULA.

It might be possible to create a skeleton in blender that mimics the kerbal skeleton exactly, possibly using a plugin, but I'm not going to do that here, seeing as it would be so much more complicated. Plus, the in-game interface is not that bad once you get used to it.

Share this post


Link to post
Share on other sites

I wasn't talking models or textures, just the transform hierarchy into an equivalent blender skeleton. But okay then ;) I haven't investigated it at all and wondered whether your current solution was because an exporter didn't work out or that you preferred it

Share this post


Link to post
Share on other sites
Exporting the kerbal model and textures might be considered stealing, and is definitely against the EULA.

It might be possible to create a skeleton in blender that mimics the kerbal skeleton exactly, possibly using a plugin, but I'm not going to do that here, seeing as it would be so much more complicated. Plus, the in-game interface is not that bad once you get used to it.

I really don't think it would be. The blender .craft importer imports models and textures for the entire craft, and all of us renderers use it. And I think squad made an announcement about it when the guy first came up with it.

Don't see why a kerbal importer would be any different...?

Also, I wasn't wanting it imported to blender for animations, I'll use your mod for that, I want to import the kerbal so I can render real kerbals in my renders.

Share this post


Link to post
Share on other sites

My first attempt at a "Kustom" animation;

https://youtube/N_2S9neN3us

Since it is a first attempt, don't expect an animation so perfect it could be mistaken for official, I just need to get into the hang of the interface.

Edited by Fred Cop
Gaaaaaaaaaaah, BBCode...

Share this post


Link to post
Share on other sites

OMG THIS IS AMAZING. This is exactly what I need for my cinematics! And possibly my up coming vid I was planning on releasing soon... :D That last GIF is pure gold :3

Share this post


Link to post
Share on other sites

Great thing! But no matter my efforts I couldn't make the Kerbal smile. I could only rotate lips can but not move.

zpNr1HB.png

Share this post


Link to post
Share on other sites
But no matter my efforts I couldn't make the Kerbal smile. I could only rotate lips can but not move.

You can make a small smile by rotating the Upper Jaw along the X or Z Axis, but any further and his/her mouth goes square.

As for the lip bones, they don't seem to work; They rotate unnecessarily and they cannot be moved.

Share this post


Link to post
Share on other sites

I've got a feeling the facial expressions may be done by blending animations in the head mesh - so not tied to the bone rig - but that's nothing more than speculation without investigation at this point.

Share this post


Link to post
Share on other sites

The facial bones are weird. You should never rotate them, just translate them up and down. Ive gotten them to work before, so they should work now, unless anything changed in 1.0.4/1.0.3.

This is really cool, would u implement this into IVA?

This is on the list of future features. I'm just a little bit unsure of how to implement it.

Share this post


Link to post
Share on other sites
I really don't think it would be. The blender .craft importer imports models and textures for the entire craft, and all of us renderers use it. And I think squad made an announcement about it when the guy first came up with it.

Don't see why a kerbal importer would be any different...?

Also, I wasn't wanting it imported to blender for animations, I'll use your mod for that, I want to import the kerbal so I can render real kerbals in my renders.

MrHappyFace, can you take a look at this? ^^^ (if you missed it)

Cause I really don't see how it would be stealing unless it was used for a game or something.

Share this post


Link to post
Share on other sites

@Endermens, The part importer is different because the part assets are distributed as separate files in the GameData folder. Kerbal textures and models are not.

It is also impossible to export most textures from any Unity game.

I checked the kerbal textures, and I got these errors:

pHfTy5E.jpg

The Texture Import Settings mentioned are part of the Unity editor, which only the devs have access to.

It's theoretically possible to export the mesh, but I don't want to do that, because that's not what this mod was intended to do.

Edited by MrHappyFace

Share this post


Link to post
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.