Jump to content

Landing legs in 1.1


Recommended Posts

 

I figured I'd start a thread here in case anyone has any ideas and wants to try working on this. Some of us looked into this a little bit on the Experimentals side, but didn't get very far. Landing legs have had the CFG modules completely changed, and it references a new transform called "deployTgt", which appears to sit roughly in the same place as the wheelCollider transform.

 

I've been experimenting with the MRS landing legs, and copied over most of the settings I had on the wheelCollider in Unity 4 into the new CFG modules, added the new transform, and toyed around with it a bit. The best result I've managed is a leg that deploys rigidly, with no suspension compression, and without the feet orienting properly (or at all). Clearly I'm missing something. I got the same results whether I compiled the part with the Unity 4 part tools, or the Unity 5 part tools.

Link to comment
Share on other sites

Unity 5 part tools???!!! You have them???  

 

Btw I am afraid of the new wheels too. Have not learnt the current ones and still can not figure out the suspension thing so I think I will have bigger problems with setting new ones. 

Link to comment
Share on other sites

1 hour ago, Jovzin said:

Unity 5 part tools???!!! You have them???  

 

Btw I am afraid of the new wheels too. Have not learnt the current ones and still can not figure out the suspension thing so I think I will have bigger problems with setting new ones. 

right here ->

 

Link to comment
Share on other sites

    MODULE
    {
        name = ModuleWheelSuspension
        baseModuleIndex = 0
        suspensionTransformName = rodMover
       
        suspensionDistance = 1
        suspensionOffset = -0.5
        
        targetPosition = 1            
        springRatio = 1
        damperRatio = 60
    }

This is what I gathered so far... still very similar to the old WheelCollider. layers 26 WheelCollidersIgnore and 27 WheelColliders are still necessary. setting mesh objects to WheelCollidersIgnore layer will make them invisible.

suspensionTransform gets moved by the WheelCollider suspension settings, can be visible mesh or invisible parent of visible mesh objects.

suspensionDistance is from root of WheelCollider out to the raycast. Think of this as distance from strut mount under the hood to the wheel axle on your car.
suspensionOffset is purely cosmetic, to adjust the visible mesh so it's not clipping too much into terrain. if you planned the setup in Unity ahead of time you might not have to adjust this at all and just set it to 0.
targetPosition is the resting position of the suspension, 0 is root of the WheelCollider, 1 is the maximum suspensionDistance. For landing legs it would be closer to 1; for rover wheels it would be closer to mid point at 0.5
springRatio is either absolute strength of the suspension or a multiplier of the settings you entered in Unity, not sure which. but higher the stiffer the suspension, assuming unity settings stays the same
damperRatio is how much force is applied against the suspension traveling direction. Higher the setting the less springy the suspension is.
boostRatio Higher the stiffer the suspension as well, not sure how it interacts with the other two settings.

the above config setting is in conjunction with Unity5 wheelCollider mass 0.05; radius 0.2. Spring/Damper/TargetPos of 1. I suspect most, if not all of the settings, are overriden in the config file. 3 such legs handles a full medium size3 tank quite adequately. 

I haven't exported any wheelcolliders out of Unity4, I assumed it wouldn't work in 1.1 since Unity5 had a major Wheel physics redo. I think KSP's wheels aren't exactly vanilla Unity5 PhysX wheels either.

Edited by nli2work
Link to comment
Share on other sites

 

Cool, that mostly matches what I was thinking. I was never 100% clear on the difference between Spring and Damper, but used some fudged numbers that seemed to work well originally. So far, I'm not sure whether it matters whether we use Unity 4 or Unity 5 to make it, since it's still just a wheelCollider and the usual set of transforms, with the same hierarchy were were used to.

 

No idea on "TsubSys" either.

 

I do get the infinitely-flinging effect on my legs if I try to use them with the old part module. With the new one, and a "deployTgt" transform that sits in the same place as the wheelCollider transform, I get rigid legs. I have a feeling I'm not using the deployTgt transform correctly.

Link to comment
Share on other sites

 

@sarbian made a tool over in the experimentals area for showing the heirarchy, and it looks like the wheelCollider transform now exists outside the animation heirarchy, as a child of the root object, so I think the deployTgt tells KSP where to move the collider when it's active. Just a hunch.

 

 

Oh also, good work on figuring out the suspension offset. I wondered why it looked like it was set opposite to the suspension distance. I'm playing around with setting my test leg to "targetPosition = 1" and using that.

Link to comment
Share on other sites

Could be. I tacked a mesh object as child of wheel collider, to see what it is doing. Its removed completely when the leg is half way retracting, and reactivated when leg is half way deploying. I suspect you can still do the old way with wheelCollider as child of a moving piece higher up in the hierarchy.

Link to comment
Share on other sites

3 minutes ago, nli2work said:

damn I gotta get Sarb's tool... what's it called? looks extremely useful

I posted in our other thread over there if it would be OK with him if I shared it here. It's just called DebugStuff.dll. :)

 

Link to comment
Share on other sites

 

No, he had it in the private experimentals area. That's why I wanted to ask him first.

 

I just also had another realization on the wheelcollider settings. I don't think it's taking into account rescaleFactor, whereas the old system did.

 

Link to comment
Share on other sites

 

This is all I'm going to have time for tonight. But I'm *almost* there in terms of the suspension. The feet aren't rotating, so that will be the next challenge.

 

Steps taken so far to convert legs from pre-1.1 to 1.1:

 

  1. In the part's CFG: Replace the "ModuleLandingLeg" with the new modules, and copy in settings from the Unity wheelCollider. New modules: ModuleWheelBase, ModuleWheelSuspension, ModuleWheelDeployment, ModuleWheelLock, ModuleWheelBogey
  2. In Unity (I'm doing it all in Unity 4.2.2 right now) : Add the "deployTgt" transform to the leg. This transform is a duplicate of the existing wheelCollider, still on the same layer, but with the actual collider removed. It stays as a child of the "pistonHolder" object.
  3. Still in Unity, move the wheelCollider transform (keeping its collider of course) out of the leg heirarchy so that it's parallel to the top GameObject of the actual leg. So it's not moved with the animation.
  4. If you're using a rescaleFactor other than "1", set it to "1", and rescale the leg in Unity instead. Adjust the suspension distances and so forth in the part CFG accordingly.
  5. Play around with suspensionDistance. So far groundHeightOffset hasn't had any effect. No idea what it's for.

Still no idea what TsubSys is. Might have to do some trial-and-error experimentation.

 

EDIT: TsubSys appears to affect the deployment animation. Very low numbers (closer to 0) result in the piston teleporting to its deployed position and back, rather than animating smoothly.

 

 

 

Link to comment
Share on other sites

 

OK, I just couldn't leave it alone, and wanted to try a few things. I have this set of legs working now.

 

For the suspension height, I just did trial-and-error until I got the right number. For whatever reason, the numbers I calculated were never quite right.

 

To get the foot working, it was also trial and error, until I could see what it was doing. It turns out that the ModuleWheelBogey settings are pretty straightforward. They do what they say, with the caveat of the two axis entries being slightly non-intuitive. "bogeyAxis" defines which axis the foot is going to pivot around, at the ankle. But the axis is defined in terms of the parent object's (the piston's) coordinate space. "bogeyUpAxis" is more obvious, as it just defines which direction is "up" in the foot's own transform-relative coordinates. If you made your foot with the "blue" (Z) axis pointing down, then you use the stock-like setting of "bogeyUpAxis = 0, 0, -1".

 

 

 

Link to comment
Share on other sites

22 minutes ago, NecroBones said:

For the suspension height, I just did trial-and-error until I got the right number. For whatever reason, the numbers I calculated were never quite right.

 

 

It turns out I was just being stupid. The numbers worked fine, but it's because of that "rescaleFactor" that I had to work around. Originally the suspension height for the wheel collider in Unity was 2.875, and the radius was 0.65. The rescaleFactor was set to 0.6. So when I set rescaleFactor=1 and then scaled down the model in Unity to 0.6, that meant that the suspension height would be 1.725, but it ended up floating off the ground. Well.. I forgot to also reduce the radius. Leaving the radius at 0.65 meant that my new suspension height should be 1.465 instead of 1.725.

 

Moral of the story--- rescaling is bad news. :)

 

 

Link to comment
Share on other sites

5 hours ago, NecroBones said:

 

No, he had it in the private experimentals area. That's why I wanted to ask him first.

 

I just also had another realization on the wheelcollider settings. I don't think it's taking into account rescaleFactor, whereas the old system did.

 

May I ask what is this private experimentals area and how can I access it?

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