Jump to content

[Tutorial] Animated Landing Leg w/ Suspension


BahamutoD

Recommended Posts

For any useful kind of diagnosis, screen grabs are really required. Even better, create a Unity package of your scene, model and any materials/textures you're using by selecting them, right clicking and selecting "export package". Assuming you're using 4.2.2?

Using 4.6.4f, but I'll have a go at that. My scene/project is one big blob of everything, and is many bignesses, and thus unsuitable. I'll have a look at the export package options.

(EDIT)

Export package only seems to grab the assets imported from blender or where-ever. The "how it's pieced together in Unity" bit is likely to be the issue. Is that still useful?

I think this should work, but as I said, in Unity 4.6.4f it seems to just export the asset, there's no option to export scene items.

https://www.dropbox.com/s/x4ktauucxsv44yd/landerlegs2.unitypackage?dl=0

Edited by TiktaalikDreaming
Link to comment
Share on other sites

Hmm. I tried to follow the tutorial, but something went very wrong. Does anyone recognize this problem? Aside from the obvious, the suspension action seems to happen between the landing leg base and the tank, and not between the landing leg and the piston.

QOIjSOl.png

EDIT: This is how it is supposed to look. Oh, and I confess, I'm using Unity 4.6.5, but could that have such a profound impact?

m65SV6C.png

Edited by greystork
Link to comment
Share on other sites

I had similar problems. Either the leg pistons wouldn't extend at all, or they would extend and retract, but with no suspension strength. I reworked it as per the tutorial probably a dozen times, but what finally fixed it was to get all of the mesh object hierarchy right in Blender, and make sure I didn't need to break the "prefab" status in Unity... then it finally worked.

Link to comment
Share on other sites

I had similar problems. Either the leg pistons wouldn't extend at all, or they would extend and retract, but with no suspension strength. I reworked it as per the tutorial probably a dozen times, but what finally fixed it was to get all of the mesh object hierarchy right in Blender, and make sure I didn't need to break the "prefab" status in Unity... then it finally worked.

I'll give that a go later today. I have a dummy cylinder matching the expected fuel tank size in my blender file that I delete, which breaks prefab. I'll kill it from blender, resave etc etc.

God I hope that's all it is. :-)

Link to comment
Share on other sites

I had similar problems. Either the leg pistons wouldn't extend at all, or they would extend and retract, but with no suspension strength. I reworked it as per the tutorial probably a dozen times, but what finally fixed it was to get all of the mesh object hierarchy right in Blender, and make sure I didn't need to break the "prefab" status in Unity... then it finally worked.

Nope, that wasn't it. I guess I'll try with Unity 4.2.2 next and see if anything changes.

Link to comment
Share on other sites

If the wrong part is moving, you've named the wrong object in this config or got confused in your hierarchy.

If stuff is floating, you've probably got the scale of the wheel colliders something other than one, a collider on the foot (which you should not), the wheel collider is child of the moving suspension part (which it should absolutely not be), or there is a collider in the path of the wheel collider raycast that is not set to the correct layer.

Though if you're struggling, I'd suggest trying something simpler first, and you should absolutely be using 4.2.2. The real issue comes with the legacy animation stuff that KSP likes to use, but for comparability purposes (so the rest of us using the correct version can read your scene file), it makes sense. There aren't really any advantages to using the later version for KSP modding anyway.

Link to comment
Share on other sites

If the wrong part is moving, you've named the wrong object in this config or got confused in your hierarchy.

If stuff is floating, you've probably got the scale of the wheel colliders something other than one, a collider on the foot (which you should not), the wheel collider is child of the moving suspension part (which it should absolutely not be), or there is a collider in the path of the wheel collider raycast that is not set to the correct layer.

Though if you're struggling, I'd suggest trying something simpler first, and you should absolutely be using 4.2.2. The real issue comes with the legacy animation stuff that KSP likes to use, but for comparability purposes (so the rest of us using the correct version can read your scene file), it makes sense. There aren't really any advantages to using the later version for KSP modding anyway.

Downgrading to Unity 4.2.2 changed nothing, except it made the Unity user interface a bit less convenient. The thing that fixed everything was moving the origin of the piston to its top instead of its bottom in Blender. Perhaps that should be added to the tutorial as well.

Edit: Also, having any keyframes on the piston will mess things up.

Edited by greystork
Link to comment
Share on other sites

I would, but it's not my tutorial ;) Baha is a little busy these days, so I try to keep an eye.

Glad you got it sorted - the origin (I'm guessing that's Blender-speak for pivot) seems to trip a few people up. Something I tend to forget because cause I've dealt with this stuff so many times. Good practice to have the animation component somewhere near the root of the hierarchy, as you seem to have found.

Link to comment
Share on other sites

Thanks, lo-fi. Its been over a year since writing the tutorial and working with legs so I'm a bit rusty.

Animations tend to overwrite position values set by code, so its important to make sure there aren't any keyframes on transforms referenced in the part module.

Link to comment
Share on other sites

I've not done too much myself, but having messed about with the wheels which are similar I have a rough idea what's going on. Maybe time for another tutorial with some of the common mistakes covered!

Link to comment
Share on other sites

I've not done too much myself, but having messed about with the wheels which are similar I have a rough idea what's going on. Maybe time for another tutorial with some of the common mistakes covered!

There do seem to be more than the usual collection of gotchyas. With legs and wheels, legs being a subset of wheels as far as I can tell.

Link to comment
Share on other sites

Yeah, the modules are very similar, which isn't that surprising given that they're wheel collider related. I guess an FOG (Frequently Occurring Gotchyas) list would be helpful in lieu of a full tutorial.

Link to comment
Share on other sites

I'm now having an odd issue with the feet hovering over the surface. I tried shortening up the piston collider and wheel collider a little, and it's still floating. Very strange.

KSP%202015-06-15%2021-32-23-14.jpg

- - - Updated - - -

I'm now having an odd issue with the feet hovering over the surface. I tried shortening up the piston collider and wheel collider a little, and it's still floating. Very strange.

http://ksp.necrobones.com/screenshots/2015-06/KSP%202015-06-15%2021-32-23-14.jpg

Fixed it, but I'm not sure why this works. I had to shorten the wheel collider's suspension distance such that the line ends above the foot pivot. It doesn't reach down through the foot at all. And now I get the right suspension height. Ugh.

KSP%202015-06-15%2021-42-02-92.jpg

Edited by NecroBones
Link to comment
Share on other sites

I'm now having an odd issue with the feet hovering over the surface. I tried shortening up the piston collider and wheel collider a little, and it's still floating. Very strange.

http://ksp.necrobones.com/screenshots/2015-06/KSP%202015-06-15%2021-32-23-14.jpg

- - - Updated - - -

Fixed it, but I'm not sure why this works. I had to shorten the wheel collider's suspension distance such that the line ends above the foot pivot. It doesn't reach down through the foot at all. And now I get the right suspension height. Ugh.

http://ksp.necrobones.com/screenshots/2015-06/KSP%202015-06-15%2021-42-02-92.jpg

Make sure you test it on terrain as well. IIRC the launch pad has a bad collider.

Link to comment
Share on other sites

Make sure you test it on terrain as well. IIRC the launch pad has a bad collider.

That it does. And a nasty habit of exploding.

My understanding is that the vehicle rests on the end of the "wheel collider suspension line", modified by weight on the springs. But also that the foot should end up moving with said end point. It shouldn't end up sitting on the piston collider, that would be the KSP equivalent of bottoming out.

Link to comment
Share on other sites

Fixed it, but I'm not sure why this works. I had to shorten the wheel collider's suspension distance such that the line ends above the foot pivot. It doesn't reach down through the foot at all. And now I get the right suspension height. Ugh.

Shouldn't the suspension become rigid if the piston collider protrudes beyond the wheel collider? I seem to recall that's what happened when I tried that.

Edit: Reading TiktaalikDreaming's post again, that's probably what he means by 'bottoming out'.

Edited by greystork
Link to comment
Share on other sites

Make sure you test it on terrain as well. IIRC the launch pad has a bad collider.
That it does. And a nasty habit of exploding.

I think the pad's collider is much better than it used to be. I was able to get very precise height tests with my older legs first, before seeing my new ones off by about 0.45m. Another screenshot showing the legs working great, on flat terrain:

(again, not sure why it works properly with the wheel collider line shortened up by about 0.45m, just above the foot's pivot).

KSP%202015-06-16%2009-20-45-53.jpg

My understanding is that the vehicle rests on the end of the "wheel collider suspension line", modified by weight on the springs. But also that the foot should end up moving with said end point. It shouldn't end up sitting on the piston collider, that would be the KSP equivalent of bottoming out.

Shouldn't the suspension become rigid if the piston collider protrudes beyond the wheel collider? I seem to recall that's what happened when I tried that.

Edit: Reading TiktaalikDreaming's post again, that's probably what he means by 'bottoming out'.

Yeah, that's what I thought too. I'm wondering if there's something funky with how it scales in larger sizes? I found that as long as the piston collider was in the right place, what was determining how much the foot would float above (or sink into) the surface was 100% controlled by how long the wheel collider line was, in this case.

Link to comment
Share on other sites

I think the pad's collider is much better than it used to be. I was able to get very precise height tests with my older legs first, before seeing my new ones off by about 0.45m. Another screenshot showing the legs working great, on flat terrain:

(again, not sure why it works properly with the wheel collider line shortened up by about 0.45m, just above the foot's pivot).

Yeah, that's what I thought too. I'm wondering if there's something funky with how it scales in larger sizes? I found that as long as the piston collider was in the right place, what was determining how much the foot would float above (or sink into) the surface was 100% controlled by how long the wheel collider line was, in this case.

I was just messing around trying to get mine to work at all and I remembered wheelCollider radius. Your's wouldn't be around the 0.45 mark would it?

Link to comment
Share on other sites

I was just messing around trying to get mine to work at all and I remembered wheelCollider radius. Your's wouldn't be around the 0.45 mark would it?

It's actually 0.65 in this case. But it's possible I just need to position it better and play with the radius some more.

Link to comment
Share on other sites

Mine just won't work at all. I'm going back and creating an extremely simple leg to see if I can get the basics working.

I used the tutorial Blend file, since that's verified to work. That's how I discovered the 'origin at top of piston' thing.

Link to comment
Share on other sites

It's actually 0.65 in this case. But it's possible I just need to position it better and play with the radius some more.

Found the problem. Somewhere along the way, I got my wheel collider position out of place with what the piston's origin (transform center) was doing. They were 0.5m apart at the end of the deployment animation. I fixed that, and it works great. I knew something wasn't right when I noticed that at the end of the deployment animation, the piston/foot assembly would "teleport" (or snap) instantly inward by about 0.5m.

It shows that the piston's origin absolutely does need to correspond to where the wheel collider's center is.

KSP%202015-06-16%2018-24-50-54.jpg

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