Jump to content

[Resolved] Need Help with Simple Animation


Recommended Posts

This problem has stumped and frustrated me for about twelve hours of heads-down development. I'm hoping somebody can help. I recently started developing parts mods. After several successes, I want to create my first animated mod.

The mod is a cylinder with a door. It is composed of three objects: the mesh cylinder, the door, and a collider (named node_collider).

I created the mod in Blender 2.71. Exported it as an FBX file, which I then took to Unity. A link to the files is below. the files I provided are:

1. GamaData directory for the part, with MU and part.cfg files. There is no MBM; there is no texture. However, the cylinder and door have colored Materials applied. Eventually, the cylinder and door will have image textures applied.

2. FBX exported by Blender

In the VAB, I can grab the part from the Utility section and attach it to the rocket. When I right-click the part, no context menu is displayed, although there should be, right?. On the launchpad, there is no context menu either. In neither the VAB nor launchpad are the colors of the cylinder or door shown. In fact, I can't even see the door. I would like a context menu displayed with a button to Open the door or Close it.

The CFG file contains this module description, which is Squad's stock animation module.

MODULE
{
name = ModuleAnimateGeneric
animationName = door
startEventGUIName = Open door
endEventGUIName = Close door
}

The part's animation timeline is 100 frames long: 50 to open, 50 to close. In Blender, the animation works flawlessly. I then created the part in Unity, following Nifty255's video (start at 10:30) instructions. To solve my problem, I watched about a dozen modding videos without success. Using an add-on to Blender, I've looked at other parts' MU files (both stock and mods) to determine where mine differ.

I would greatly appreciate it if you could glance at the files in Blender or Unity. I'm sure I'm missing just one small thing.

Edited by Apollo13
Link to comment
Share on other sites

I just found out how it works my selfe, so I can only give pointers with no garantee, that it's the right way or the best practice..

- I use the blend file to import - not fbx - works well

- I was told to set the "rig" to legacy

- it might be, that your animation name is the one you set in blender, but you forgot to name it in unity on import.

unity uses "default take" - there should be door

- also something that went wrong here, the right click thing does reverse the first animation on close - afaik it does not use your close animation..

- afaik the context menu in editor needs a plugin to show animations - something like advanced animator or tweakables - I forgot wich one is to blame.

- afaik, color materials are not supported by KSP

- if you don't see a part, it usually has too many materials in unity - only one can be used for KSP

I hope these infos help a bit..

good luck..

Link to comment
Share on other sites

I think I see the problem, or at least the first one... and it drove me nuts on my first animated part.

When I opened your fbx in Unity and set the rig to 'legacy mode' then open the animations tab... you've got 3 separate animations for your part's different actions. Unity is expecting it to all be baked into one animation!

To make that happen, in the blender .fbx export window - scroll down the options on the left side. You want 'baked animations' checked but you want 'nla strips' and 'all actions' unchecked! By default my blender installation had those two checked and it caused the files to look exactly like yours!

Now... load the new fbx into unity and when you get to the animations tab you should see a single animation instead of 3 - probably named 'Scene'. You can now follow the instructions in Nifty's video to split the 'Scene' animation into the two 'clips' that you want... name the first clip 'door' and you should be there.

Let me know if that helps or not, or if it gets you a step closer and we'll figure out what's next!

Art

Link to comment
Share on other sites

in addition to what's been said,

your config file is calling for "door" animation (capitalization matters); your FBX has "Door|DoorAction.001", and presumably in your MU as well. the module won't find the animation, and you won't get any menu in KSP.

Link to comment
Share on other sites

Getting closer!!!!!!!!!!!!!!!! THANK YOU ALL for your help

I baked the animation, per artwhaley. This created a clip called Scene (did not rename to "door"). In the CFG file, I set "animationName = Scene" per nliwork; I ensured capitalization matched.

I've not created an image texture mesh yet, because i don't want to change too many things at once. Philotical, thanks for that info about color materials and reason for no context menu in VAB.

RESULTS:

On the launchpad (facing towards the VAB), I right-click the door and a context menu pops-up with the "Open door" option. I click that button and the door opens to reveal the inside of the cylinder. However, the door immediately closes again. When I right-click the door, the context menu shows the "Close door" button. The door opens and closes.

In Unity, in the Animations section, I set frames 1-50 to the open door action. I set frames 51-98 to the close door action.

Bottom line: it's playing the entire Scene clip, not just the sections I assign to each state.

Edited by Apollo13
Link to comment
Share on other sites

You're within 6 minutes of done! Before I saw that you were mostly there, I recorded a quick video where I took your blender file and got it all the way through to KSP and it's working just fine.

The video is a little blurry... so if you can't see any of the things I'm doing... or if things look different on your end just ask!

I deleted the stock tank inside the model because I assumed you used it as a size reference... then it occurred to me that it might have been the payload. It won't change the final outcome either way if you delete it or leave it. I did delete the blender camera and lamp while I was in Unity.

I'm a little confused - when you said you didn't rename the single animation, but did say that you set the open and close actions to keyframe ranges...

Philotical is correct that the moduleanimategeneric plays the animation forward the first click and then backwards the next click... so what you've done should work great if you just jump back in the animations tab of Unity, select "Scene" and change the ending keyframe to 50 then re-export to KSP.

So you're actually within 30 seconds of it working. :)

In the video you'll see me rename the Scene file to door to match the .cfg file you already made. It will work fine either way. I also went ahead and split the second half of the Scene clip into a separate animation in case you want to do something more complicated later, but right now KSP is ONLY using the first one and just playing it forwards on open and backwards on close, so just setting the new ending keyframe should be all you need to do.

Art

Link to comment
Share on other sites

you want just one clip for open; no need for close clip. In import settings, only use frames 1~50 for door open. Name the clip something you want. In Animation component; make sure the size is 1; and the two fields displaying animation clip match the door open clip you setup. uncheck Play Automatically box.

in config file, make sure the animationName match your setup in Unity.

KSP plays the clip you call with AnimateGeneric; and stops on the last frame of the animation. Then reverses it when you click the endEventGUIName button. so if your clip has both door open and close; you see it open then close in KSP. and it'll look the same played forward or backward.

Link to comment
Share on other sites

WE HAVE LIFTOFF!!!!!!

artwhaley: thank you for the video. Given what I learned from Nifty's video, I was able to follow along and understand what you were doing. And, I've got your video is a favorites list for future reference. The stock tank was just for reference.

arwhaley, nliwork: I changed the animation in Unity to use only frames 1 through 50. The door opened AND STAYED OPEN. Right-click again, and I shut the door.

I will investigate doing a more complex animation in the future once I've got this locked in to my mind. I'll open a new thread as well for that.

THANK YOU ALL AGAIN. I gave you all forum Rep points as well. Unfortunately, the forum will NOT let me give a Rep point to nliwork. Apparently, I gave him too many for now; I'll add in the future.

Hopefully, this thread will help other modder newbies like me.

Edited by Apollo13
Link to comment
Share on other sites

Glad we could help apollo

nli2work and Art, may I ask a nooby follow up?

Why do you bother with fbx?

if the blend, preconfigured with animations, is in assets, you can select it and then create, name and import your animations.

I set them up in blender, and in unity I click on "+" as often as I need and name them individually - later I can call an unlimited amount of such animations in my script..

Works well for lots of doors, trains and turbolifts in my two walkable ships..

Since this works so well, I never bothered to try fbx.

Is there any kind of advantage to have them as fbx?

I'm aware, blend import is a new feature - for me it was the first I tried.. - I'm new too :-)

Are you guys just used to the "old" (for lack of better term) way or do I miss the point here?

Sorry for the confusion - but so many different tuts tell so many different things that it's hard to find out what is the best practice..

if someone feels compelled to answer, thanks in advanced..

Link to comment
Share on other sites

nli2work and Art, may I ask a nooby follow up?

Why do you bother with fbx?

if the blend, preconfigured with animations, is in assets, you can select it and then create, name and import your animations.

I set them up in blender, and in unity I click on "+" as often as I need and name them individually - later I can call an unlimited amount of such animations in my script..

Works well for lots of doors, trains and turbolifts in my two walkable ships..

Since this works so well, I never bothered to try fbx.

Is there any kind of advantage to have them as fbx?..

When I try to import BLEND files directly, I get a Windows dialog message that says the "Blender has stopped working"

I'm going to follow-up/PM with you about the multiple animations that you mention. I want to learn that as well.

Link to comment
Share on other sites

Glad we could help apollo

nli2work and Art, may I ask a nooby follow up?

Why do you bother with fbx?

if the blend, preconfigured with animations, is in assets, you can select it and then create, name and import your animations.

......

Sorry for the confusion - but so many different tuts tell so many different things that it's hard to find out what is the best practice..

if someone feels compelled to answer, thanks in advanced..

It's exactly because that's what the first tutorial I followed did... and so now that I have a process that works I haven't wanted to mess with it and spend time learning the kinks of a new method. I probably SHOULD learn how to send blend files straight to unity - I'm sure some day I'll be banging my head against the desk over a problem that would have just been fine if I hadn't been converting to fbx! But I haven't gotten there yet... so I've just kept modelling stuff the way I'm used to because modelling stuff is more fun than relearning how to make the programs talk to each other!

Art

Link to comment
Share on other sites

Unity converts it to FBX anyway. If you import a blender file, Unity does it for you using Blender's FBX exporter using some settings you don't know, which may or may not work as you expect it. If you import max file, unity does the same thing using Autodesk's FBX exporter.

Going from 3d app to unity is a pretty important step and I want to know what the conversion is doing as best as I can; if there's a problem with the import in Unity, it's easier to track it down and fix it.

Link to comment
Share on other sites

snip

fair enough - though if the blend is in assets and you have no version troubles like apollo seems to have, the import is self explaining (almost) and has many settings if needed..

you might find it not to be that hard at all..

what ever suits you most is my moto..

:-)

snip

I see - I will make a deeper analysis of the settings offered one of these days..

still the additional clicking and additionaly files is a downer for me - maybe if an animation fails once, it's good to know there could be a fallback solution, or if I need a more sofisticated thing as up to now.

But generally, blend import is a great feature for my taste and needs so far..

I appreciate the input..

Thank's guys..

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