Jump to content

[SOLVED] Landing leg problems


Recommended Posts

I've been following the tutorial from BahamutoD to try to make SpaceX-style landing legs. I discovered pretty quickly that just doing rigid legs with ModuleAnimateGeneric is not good on high-mass, and large-scale rockets, so I'm trying to make a suspension system like normal legs.

The legs start in a vertical position, then swing down to around 55 degrees below horizontal. I have the piston "working" in the sense that it instantly (no animation) pops out when the deploy animation finishes, with a distance equal to "suspensionUpperLimit" from the CFG file. I'm not setting up the foot to orient to the ground. The feet appear to collide with the ground properly, and the piston shaft retracts, but doesn't appear to apply any strength at all, no matter what numbers I use for Spring and Damper. So the craft continues to sink at full velocity until the leg-fin's collider hits. The foot/piston never retracts via animation, so retracting the legs will leave them sticking out the end (not intentional).

I made the animation in Blender, with all of the parts except the hinge object rotating with that anamation to deploy. They all have a transform origin right at 0,0,0, and rotate around that origin. The large collider for the fin/leg is from blender, and set to wheelCollidersIgnore. Other colliders are capsules in Unity, one for the piston shaft, and one for the hinge. The hinge collider is attached the root gameObject, and is on the default layer, since it never intersects the wheelcollider.

Any ideas what I'm doing wrong?

I've been trying all sorts of numbers for suspensionUpperLimit, impactTolerance, suspensionSpring, and suspensionDamper, so below are just what was in the last test.


MODULE
{
name = ModuleLandingLeg

animationName = extend
wheelColliderName = wheelCollider
suspensionTransformName = SYlandingLeg2piston
suspensionUpperLimit = 1
impactTolerance = 800
suspensionSpring = 25
suspensionDamper = 5

orientFootToGround = false
landingFootName = SYlandingLeg2foot
// Axis is aligned forward instead of up
alignFootUp = false
}

Current wheel-collider setup below. I've also tried placing it near the "top" (foot) end of the leg, as well as somewhere in the middle. Right now I have it toward the hinge, with a piston-shaft that is long enough to reach that point.

The odd scaling is an artifact of importing with FBX and having to scale the part up in the export from Blender

MOK2vDu.jpg

Stowed and deployed views (they're intended for 5m tanks, so they look odd on 2.5m, but I'm testing with a smaller tank to have a better view of the suspension strength):

KSP%202014-12-20%2011-12-41-93.jpg

KSP%202014-12-20%2011-13-09-95.jpg

KSP%202014-12-20%2011-13-54-58.jpg

Edited by NecroBones
Link to comment
Share on other sites

Looks like you've got it how it ought to be hierarchy wise. The only problem is that the wheel collider needs to be near the tip of the wing with the raycast sticking out equal to the expected travel of the piston. As it is, it won't be doing anything. The position of the circle on the wheel collider represents its upper movement limit, and the length of the 'tail' represents is maximum extension. Get that sorted and you'll have it all working, I'm sure :)

Link to comment
Share on other sites

Looks like you've got it how it ought to be hierarchy wise. The only problem is that the wheel collider needs to be near the tip of the wing with the raycast sticking out equal to the expected travel of the piston. As it is, it won't be doing anything. The position of the circle on the wheel collider represents its upper movement limit, and the length of the 'tail' represents is maximum extension. Get that sorted and you'll have it all working, I'm sure :)

When I try that, the piston comes all the way out, such that the back end of it is where I put the front end of the wheel collider's suspension line:

Darn, I thought we were onto something. :)

EDIT: And it still has no spring strength, and compresses in until the main collider hits the ground.

EDIT 2: I also double-checked that WheelCollidersIgnore is layer 26, and WheelColliders is 27.

KSP%202014-12-20%2016-31-31-82.jpg

gQ2J8n5.jpg

Edited by NecroBones
Link to comment
Share on other sites

Oh, just noticed that the wheel collider is set to something other than scale 1. They do weird stuff when scaled, so that might be causing the issue too. Also, I've found that putting them in layer 26 sometimes results in non functional wheel colliders, so try it back at default if resetting the scale doesn't work.

Feel free to package up and send over if you're still stuck after trying that, though.

Link to comment
Share on other sites

Yeah, that looks like it's not the problem. I tried that and it behaves the same. No dice. Doh!

In the screenshot below, you'll see that I added a "pistonTransform" in the middle. I tried to animate that to have the leg piston deploy while the leg is swinging around, without animating the piston object itself (per the tutorial's warning). This makes the MU not compile, with KSP claiming "out of memory" errors. Very strange. So I put the animation back the way it was for now, but the transform is still there doing nothing.

Silly question-- What's the best way to package up the unity object/assets? I haven't had need of importing/exporting them til now. :) I just tried the "export package". We'll see how that looks below. EDIT: also did a "save scene as" below.

As an aside, the piston-shaft is quite long. It doesn't need to be. Originally I had it a lot shorter, and then lengthened it when I thought I might need to put the wheel collider toward the hinge-end of the leg. It's closer to working properly in that configuration, but the behavior is always the same-- the piston shoots forward to be at the end of the wheel's suspension line, instead of inside it, and then there's no suspension strength.

So very, very strange.

BTW, thanks for helping! Hopefully we'll get this figured out. It feels close... ;)

Here are the files. The scale in Unity is a bit annoying when importing FBX, but that seems to be the format that works nicely with the animations for my other parts.

Unity asset export: http://ksp.necrobones.com/files/testing/landing-leg.unitypackage

Unity scene export: http://ksp.necrobones.com/files/testing/landing-leg.unity

Blender: http://ksp.necrobones.com/files/testing/SYlandingLeg2.blend

FBX: http://ksp.necrobones.com/files/testing/SYlandingLeg2.fbx

Texture: http://ksp.necrobones.com/files/testing/SYlandingLeg1-Specular.png

EDIT: The KSP part as of the last test: http://ksp.necrobones.com/files/testing/landing-leg-part.zip

EDIT: Fixed the uploads. Didn't transfer properly the first time.

3LHS2zW.jpg

Edited by NecroBones
Link to comment
Share on other sites

No worries :) I've not actually tried setting a landing leg up myself, but they're just wheel collider based and sort of within my areas of expertise (if you can call it that).

Thanks for uploading, I'll have a nose through the assets tomorrow and see what I can find. I'm sure you're not far off! I just downloaded the part, so I see what you mean about the lack of spring strength - I'm still pretty sure this might be a scale issue, as those radius and distance values are odd to say the least. That the piston extension works is testament to the WC raycast doing its job, as the module is moving the piston, though the travel is way over the top judging from the latest screen grab, so that's kind of another clue. I've struggled with this myself, it can be a nightmare when exports have funny scales and you need an object childed to something that's way out of whack.

Regarding the animation export issue, you can get some weird issues when you've got an animation in the export, then add some stuff in Unity. I've had part toolts throw a similar paddy myself, though your situation may be different.

Link to comment
Share on other sites

Making a landing leg with suspension is a huge pain. Maybe even worse than a wheel.

Here's some images of the landing leg from my Odin pod. took me forever to get them working even halfway right.

Javascript is disabled. View full album
MODULE

{

name = ModuleLandingLeg

animationName = Deploy

wheelColliderName = wheelCollider

suspensionTransformName = lowerPiston

orientFootToGround = true

landingFootName = Foot

// Axis is aligned forward instead of up

alignFootUp = true

suspensionUpperLimit = 0.3

impactTolerance = 6500

suspensionSpring = 10

suspensionDamper = 7

}

whellCollider is at the bottom of the piston travel, its origin closely matching where the origin of lowerPiston (the leg's transform and also the silver inner piston model) will be when extended. and the end of the wheelCollider's "line" reaching to the Foot when extended. Note that since lowerPiston is the transform in the config, the module moves it and any children along the suspension length.

The pistonCollider is the one that will actually touch the ground and travel with the suspension. The Foot itself should not have a collider. ANY Mesh collider that interacts with the wheel collider will probably cause it to fail and let the leg collapse. That is why I have the simple box collider "objCollider" to provide collision for the upper part of the whole thing.

My animation is imported from Blender as "Deploy" with frames 0 to 99 using the Legacy rig, its contained on the Odinleg2 parent object as an Animation widget.

Maybe all of that will let you figure out what to do with yours. Its mostly trial and error and trying not to punch things.

Link to comment
Share on other sites

OK, got it sorted :D I'll try and be concise explaining to ease future reference: Tiberion hit the nail right on the head for your situation with "wheelCollider is at the bottom of the piston travel, its origin closely matching where the origin of lowerPiston (the leg's transform and also the silver inner piston model) will be when extende" You had some interesting things going on with placement, so I've re-rigged: Set the WC transform to the position it wants to be in, rather than using the centre variable to located it. Added a GO called PistonMover, which sits in exactly the same location as the WC and has the piston as a child. The piston is rigged in its extended position by moving it it relative to PistonMover. This is why the feet were in funny positions.

Most importantly: The Wheel Collider must not be a child of the piston. It needs to be in a fixed position. What was happening was the raycast was doing its job, detecting a collision and compressing against the spring value. ModuleLandingGear was doing its job and moving the piston a tiny bit to mirror the compression. The next physics frame, as the WC is a child of the piston that's just been moved, the cycle happens again. collision, compression, movement - every frame, the WC got moved further away from the floor until the leg collision mesh stopped things going any further, and this is why there appeared to be no spring acting. It's the most common mistake making wheels actually, I just didn't spot it in the screen grab.

This should be everything re-rigged :) Sorry, I was lazy and didn't reapply the texture ;)

Would you mind if I used the model to do a YouTube landing gear tutorial please?

Link to comment
Share on other sites

Hey thanks! I wasn't expecting anyone to figure it out "overnight" literally. :) Yes, please do use it for a video! You've definitely earned it. I'll download it and play with it a bit. I was about to push out a SpaceY update this morning without it, but maybe I'll try to sneak this in now.

I had gotten an email notification about the first reply after my last message, so I was going to come in and just talk about the object scales, so this was a huge surprise!

But I'll explain the scaling anyway. The reason the scales look so weird is twofold: First, exporting as FBX requires scaling by 100x for some stupid reason. Secondly, I had scaled the leg up a little in blender via multi-select in object mode, so it scaled the transforms instead of moving the vertices.

Thanks again!

EDIT: This is silly, but how do I import it into Unity? When I try to "import custom package", it shows me that there are some materials to import. I don't see the game objects showing up in the list. Man, I can be such a Unity noob. :)

EDIT 2: I may try to recreate what you did anyway. I'm thinking about untangling the funky scaling, shorten the piston, etc. And I need to know how to make it work anyway, for the future.

Edited by NecroBones
Link to comment
Share on other sites

No drama dude, I'm well used to messing about with all things wheel collider now, so pretty much seen it all before. I did mess about with some of the scale stuff a bit, but it didn't seem to matter here, so false alarm on that one. Shout if you run into any other problems, and thanks for the use of the model :)

Oh, btw, you might want to tweak the friction values a bit. The defaults are like super glue - a bit of slip will prevent tripping and sticking. 300 extrem, 150 asym ought to be good figures. Add a little damping too; 5-10 percent of spring value normally works well.

Link to comment
Share on other sites

No worries. :)

Thanks again for all the help. It looks like I have it working just based on what you described. I was really REALLY close, apparently. I untangled the weird scales, re-imported from Blender with a scale of 1 (via Collada/DAE), and redid the animation entirely in Unity. This allowed me to easily telescope the foot outward during the deployment sequence. So far I think it's working, I just need to tune the spring and damper.

I see what you mean about the super-glue effect. It sticks quite a lot even with much lower numbers here.

Wow, I might actually have this working and get a copy released today.

Thanks again!

Link to comment
Share on other sites

Awesome, that's great news. So many people have, and continue to help me, I'm trying to pay it forward as much as I can now I have some knowledge myself. Good call on the animation, I often do the same thing myself. Though I'm finding more and more that I tend to set up the hierarchy before I export, so all I have to do is add some colliders and whatnot, slap some materials on and write the part out. Having the prefab connection intact is really handy too.

Good luck with the tweaking, you're on the home stretch now :)

Link to comment
Share on other sites

Awesome.

They're mostly working now. I have the pistons deploying during the animation, etc. But here's the remaining weirdness:

1. The legs animate deploying, and retract properly if you interrupt the deployment. But once deployed, retracting is instantaneous, without animation. They teleport back.

2. It's not really saving the deployed state. If I quite the game with a vehicle landed, and come back in, the legs are retracted and it falls onto the engines.

A little bit of a head-scratcher. I haven't been able to find a reason for these. They're not really game-breaking (except if your vehicle falls over or breaks across sessions because the legs are retracted).

EDIT: And it's not telescoping anymore. Man, these things are ridiculously touchy.

Edited by NecroBones
Link to comment
Share on other sites

Yep, that's perfectly normal. The wheel collider doesn't understand how KSP has attached it to a rigidbody, so it thinks it isn't attached to one and throws a warning. Maybe double check the animation length, etc? No warnings in the Unity console when you write the .mu out?

Link to comment
Share on other sites

Nope, no errors or warnings. Man, I could swear it was telescoping on my first try after re-doing it from scratch. I've had to recreate the animation a few times, as every once in a while, adding too many curve keys or something seems to make the part go back to that "out of memory" error in KSP.

At the moment I've simplified the animation not to deploy the piston, and instead start with it extended. Completely rigid. And still teleporting when retracting the leg. I tried changing the wheel collider's suspension line to be a bit longer or shorter, and tried the animation's "play automaticall" checkbox both on and off. Tried various spring and damper values, and lowered the wheel collider's friction numbers considerably.

Unfortunately I still haven't had a chance to look at what you did with it, since I still don't see a way to import the GOs, just the model and assets.

Link to comment
Share on other sites

The unity scene, if you import it, and the relevant models are there will have everything all nicely rigged up. Wait a minute, how are you animating the piston telescoping? Do you have a GO that's named as the suspensionTransformName with the piston as a child, and it's that that gets animated, not the GO named as suspensionTransformName?

Feel free to send over again, though.

Link to comment
Share on other sites

OK, I can bundle it up again.

The pistonMover transform and the WheelCollider are at the same level in the heirarchy. The swing animation is animating the object that is the parent of both of them. In animating the piston (which I have removed, but that's not making a difference), it is moving the child object (with the piston mesh) under the pistonMover, which in turn has the piston collider and the foot as children. So I'm not animating the pistonMover which referenced in the CFG.

This time the animation is built entirely in Unity instead of coming over from Blender.

Unity package: http://ksp.necrobones.com/files/testing/Leg2.unitypackage

Link to comment
Share on other sites

OK, that all sounds perfect. I'll finish up what I'm doing (which is driving me nuts, but for very different reasons) and have a look.

Awesome, thanks. :)

BTW, I also now updated the DAE and Blend files in case you want to see those:

http://ksp.necrobones.com/files/testing/SYlandingLeg2.blend

http://ksp.necrobones.com/files/testing/SYlandingLeg2.dae

Link to comment
Share on other sites

  • 3 weeks later...

Just a follow-up here. I finally got the legs working (though I'll have to play a lot with the spring/damper values, as I'm not 100% clear on how they work).

What it came down to was the prefab status, and setting the piston's origin in Blender to correspond to the top of it, and then creating the hierarchy there BEFORE exporting to Unity. Everything else, I did pretty much the same. But if I made sure it was all nice and clean in Blender first, and maintain the prefab status, then things started working well enough that I could tweak it and get some actual springiness.

What a pain landing legs are. They're amazingly picky.

Link to comment
Share on other sites

What it came down to was the prefab status, and setting the piston's origin in Blender to correspond to the top of it, and then creating the hierarchy there BEFORE exporting to Unity.

^I cannot encourage this enough, it makes life so much easier. My entire workflow is based around having the model export ready to be dropped into Unity, colliders, textures and part tools applied, then just being able to click the 'write' button after double checking the config values match and I haven't typo'd anything. Your second set of landing legs will be much easier ;)

Great to hear that you got it working, though :)

Link to comment
Share on other sites

^I cannot encourage this enough, it makes life so much easier. My entire workflow is based around having the model export ready to be dropped into Unity, colliders, textures and part tools applied, then just being able to click the 'write' button after double checking the config values match and I haven't typo'd anything. Your second set of landing legs will be much easier ;)

Great to hear that you got it working, though :)

Yep, thanks again for the help! I actually have several sets of legs working now, in testing. The first is always the hardest. :)

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