Jump to content

Cargo bay doors with physics


Recommended Posts

Not only do the cargo bays not allow you to attach anything to them, they also let through light in the editor. Since there is the Infernal Robotics mod, I assume it shouldn't be too difficult for Squad to make cargo bay doors you can attach things to and now, with the large changes to the game coming in the upcoming update and a large amount of code being reworked, it's the ideal time to change this. Players could stuff much more things in their cargo bays this way while still being able to e.g. deploy satellites from it.

 

Edited by theend3r
Link to comment
Share on other sites

To cut a long story short - and take it from someone who's played with the inner workings of Unity joints and animations quite extensively - this isn't going to happen. I'm afraid you're by no means the first person to have to idea. The answer why lies in how joints, rigidbody physics and animations work, which I won't go into.

Link to comment
Share on other sites

1 hour ago, Snikersnee said:

Well the cargo bay doors probably were built to handle the weight of the doors and the doors only. I think this would be better as a mod.

"Open the cargo bay doors, HAL."

"I'm sorry Jeb.  I'm afraid I can't do that."

"What's the problem?"

"I think you know what the problem is just as well as I do."

"What are you talking about, Hal?"

"Some idiot attached Kickback boosters to each door."

Link to comment
Share on other sites

1 hour ago, lo-fi said:

To cut a long story short - and take it from someone who's played with the inner workings of Unity joints and animations quite extensively - this isn't going to happen. I'm afraid you're by no means the first person to have to idea. The answer why lies in how joints, rigidbody physics and animations work, which I won't go into.

It's doable with a mod but not in the stock game? :huh:

The bay doors have collision when the vessel is loaded. I don't have KAS but if it's possible to attach anything to the doors with it then the programming solution should be trivial.

The worst possible solution would be to simply create an invisible node and transform its position and rotation when the doors open, but I'm sure a far better/easier solution is possible.

Link to comment
Share on other sites

1 hour ago, lo-fi said:

To cut a long story short - and take it from someone who's played with the inner workings of Unity joints and animations quite extensively - this isn't going to happen. I'm afraid you're by no means the first person to have to idea. The answer why lies in how joints, rigidbody physics and animations work, which I won't go into.

How does the robotics mod do this then?  They allow rotation/changing angle of a part.  They have both turret rings and cannon elevation mountings, so why cant the same concept be applied to bay doors?

What does that mod do that cannot be done in the stock game through some way.  And the robotics code is (from my experience) one of the more stable and crash/bug free ones, so it isnt just some redneck workaround to a problem.

That said, id much prefer the robotics mod (or something similar to it) to become stock since having to make stock turrets is kinda hard, not to mention tanks using them tend to lack accuracy outside of point blank range.  And even for the non-military player such functionality would be very useful as it would open true thrust vectoring engines, custom cargo bays (as in wings used as cargo bay doors), stuff like grabber arms liek those used on shuttles, ect.

Edited by panzer1b
Link to comment
Share on other sites

3 hours ago, theend3r said:

It's doable with a mod but not in the stock game? :huh:

The bay doors have collision when the vessel is loaded. I don't have KAS but if it's possible to attach anything to the doors with it then the programming solution should be trivial.

The worst possible solution would be to simply create an invisible node and transform its position and rotation when the doors open, but I'm sure a far better/easier solution is possible.

As usual, a little knowledge is a dangerous thing. IR works by splitting parts into two, messing with some rigidybody stuff, creating a joint between the two and rejointing the attached part(s) to the freshly made rigidybody.

Listen closely, because this is the important bit: Unity joints of any kind get attached to the rigidybody in any hierarchy, not individual colliders. This is a vitally important distinction to make.

So yes, you can use a collider for placement to attach something to a KSP part (which is implementing rigidybody), but you're not actually attaching the joint to that collider. See the problem? Now this doesn't matter normally, but since cargo bay doors are animated in a non kinematic way (the physics engine doesn't really care that you moved a collider that you perceive you attached something to), the bay doors will move, and whatever you've tried to jam onto them won't. Add a rigidybody component to the GameObject of the bay door, add a joint between and then attach your part the the RB compent you've jsut created, and you have a working solution (IR). Except you can't animate a Unity joint in the same way you can as a simple child GameObject, and you've got all the fun of physics to worry about instead of your doors being solidly attached to your bay like they used to be.

There's nothing "trivial" about it.

Link to comment
Share on other sites

So as I understand from lo-fi's explanation, it would basically involve making the doors entirely separate pieces from the cargo bay itself, leading to !!FUN!! and physics wonkyness?

Link to comment
Share on other sites

Well, yeah, but it seems a little pessimistic to me. I know nothing about Unity and how it works, but I would wonder why not have three sets of collider and RigidBod, one for closed, one for open, and one for transitions/animations. You'd have to go through and move attached parts from one to the next as you went from set to set, but I would think it's possible...

Link to comment
Share on other sites

2 hours ago, lo-fi said:

[snip]

Thanks for the explanation, I suspected as much.

46 minutes ago, godefroi said:

...I would think it's possible...

It is but it just seems it's not worth it for such a little gain. I'd love it for BDArmory missiles but mods don't come into this equation.

Link to comment
Share on other sites

OK.... Given that it's not particularly viable or practical in stock to allow surface attachment to bay doors, could it be possible to add toggleable solar panels and/or radiators to the part directly?

In the editor right click on the door and get an 'add solar panel' and 'add radiator' option.  A suitable amount of mass could be added too.  This would also have the benefit of not adding to part count.

Link to comment
Share on other sites

The cargo bay doors don't have a proper collider when they're closed. Anything that is attached inside the cargo bay is free to flop around and project through the doors outward, instead of bumping into the inside of them (or knocking them open). The doors also won't hit anything on the way open and happily clip through anything that is in the way, instead of damaging it or pushing it away.

I'd be perfectly happy with doors that can't have anything attached to them, as long as they do act like proper doors should instead of just looking like doors.

Link to comment
Share on other sites

18 hours ago, hurric said:

I for the life of me cannot even figure out how to put things in the cargo bay...

Post a new thread or screenshot with your problem and I might be able to help. 

Edited by Snikersnee
Link to comment
Share on other sites

19 hours ago, hurric said:

I for the life of me cannot even figure out how to put things in the cargo bay let alone on the flipping doors ;.;

Best way I've found so far is to put together your cargo separately, make sure you set the part you want to attach it by to be the root, and then save it as a subassembly.  Then build/load the ship you want to put it in, load the subassembly, and hold down Alt while placing it to force node attach mode.

Link to comment
Share on other sites

14 minutes ago, hurric said:

Subassembly .... is this something to do with the (merge) feature in the VAB ?

Not exactly, but it works in a similar way, and a bit more reliably from my experience.

 If you click the arrow at the top left above the parts list it adds a new column with more icons, one is a green rocket which is your 'Sub Assembly' tab.  Clicking on this opens a column for your sub assemblies.  You can drag your ship into the box at the bottom and it gets added to the column.  To add an existing sub assembly to a vessel that you are in the process of building open the sub assembly column and select the one you want.  It then appears in your build space like a new part does and you can attach it to available nodes.

The Sub Assembly/Merge functions can be a bit fiddly to use as you need to ensure that the 'root' of your sub assembly is the bit you want to attach to your vessel. So usually it will be a decoupler or docking port on one end of the assembly.

Link to comment
Share on other sites

Bit OT but I had a problem with cargo bays too. I just couldn't get docking ports to stick to attachment points no matter how much I prayed or swore. Attachment points at ends of cargo bays seem to repel docking ports for some reason but they happily accept batteries and fuel tanks etc. All of my shuttles have a battery at front end and monoprop tank at rear end and docking ports are attached to those.

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