Since people seem to constantly have issues getting plane animations to work, here’s a quick checklist of things to run through.
Guide to Troubleshoot
What’s this about?
People constantly have trouble getting their landing gear to retract when it comes to modding – at least, that’s what i gather.
Typically, there are two responses to this.
- One: Remove the gear.
- Two: Don’t even animate it.
There are generally better ways to respond to this.
I’m going to assume you’ve got the model, you’ve wiggled the gear and animated it already in blender – so how do you set this up?
Of course, you might gravitate toward the default plane animator, and it does have the only parameter you’d need – that being the bool parameter, landing gears.
If you have the beta tools, somewhere you’ll have the test-tomcat’s animator. I personally use that instead since it has more options, but they might not be necessary for you to mess with.
If you have airbrakes, afterburners, or want to have certain things deploy at certain speeds in certain directions – you might get some use out of it.
Input Y is more or less ‘are you holding W or S’, velocity Z would be how fast you’re punching forward – I never really use the other ones, but with testing you can understand what calls them.
Where landing gear won’t work on helicopters, the inputs and velocity settings will, which is neat – but the weird thing about these is they aren’t mentioned anywhere in the vehicle or plane scripts.
However, if you’re here, you’re having trouble getting the gear to deploy – so let’s get back to that.
Note: the ‘landing gears’ parameter does not work on helicopters.
So here’s a few reasons why your landing gear may not work, and things to check:
- You forgot the animation controller.
- Your hierarchy doesn’t match what you animated with.
- You didn’t connect the animator to the script.
- You masked it wrong.
- Your transitions aren’t set up in a way that lets the animations play right.
Most of these are self explanatory, though some may need more elaboration.
There are two things I think I have to explain here.
This is the stock plane in blender – note how the landing gear are named and how they’re just hanging out in the open, so to speak.
This is the stock plane’s hierarchy in Unity. The landing gear are named as they were in blender, and aren’t hidden off in the plane fuselage or something.
Now, you don’t have to have your landing gear hanging out in the open – but the point with this issue is that if you rename any part that’s animated in your model, it will not work when you try to animate it. You can test this with one of the guns – take the stock AK, rename the mag, and try to reload – the magazine won’t move at all because the name doesn’t match up now.
Unparent the mag from the body, and it still won’t work because now it’s in the wrong place.
You can do whatever you want to the parts that aren’t animated, jam them into a new game object – I like to organize my own hierarchies like so:
Here, my animator’s in the spaceframe object, and the hierarchy – at least, the bones I use to animate my planes – matches what I had in blender.
My animator may not be in the same object as the vehicle script, but I have it connected to said vehicle script, and thus it works.
Thus, onto the other point I should elaborate on – connecting the animator.
This is the stock plane, as you know. You probably tried to copy the setup so your plane works.
There’s a critical flaw right now with the stock plane – and the bomber, for that matter.
The animator isn’t connected.
If you export this plane to test it for whatever reason, the landing gear will not work – until, that is, you reconnect the animator.
A disconnected animator will screw you over when everything else seems to work.
Connect it and it works.