Jump to content

Cargo bay doors and surface attachment.


Recommended Posts

Hey all, I have a bit of a question, that I'm hoping someone can help me with.

I'm trying to make some cargo bays, and I want to replicate the behavior of the (now stock) SP+ cargo bays, in that the body of the bay accepts surface attachment, but the doors do not. So far, I have the collision meshes animating properly, but surface attachment appears to be all or nothing. If I allow attachment, the VAB allows parts to be stuck to the doors, which of course results in "floating" parts, and the doors pass through them when animating.

Is there a layer setting or something, that will specify certain collision meshes as being non-attachable for surface attachment?

Link to comment
Share on other sites

I had a go with the .mu importer and a little plugin to write the layer of specific game objects to the log. No luck so far. What appears to be bay door colliders do not seem to exist (gives null-ref), and the doors themselves are layer zero. Unless it's driven with tags...

Ask Porkjet?

I'll keep you posted if I do find anything - it will be useful for one of my projects.

Link to comment
Share on other sites

Bingo!! The tag is set to NoAttach.

For reference, I used the following code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;


namespace UtilPlugins
{
public class LayerFinder : PartModule
{
[KSPField]
public string objectName;


GameObject _gameObject;
[KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "layer")]
public string thisLayer;
[KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "tag")]
public string thisTag;




public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
_gameObject = this.part.FindModelTransform(objectName).gameObject;
if (_gameObject != null)
{
thisLayer = _gameObject.layer.ToString();
thisTag = _gameObject.tag.ToString();
}
else
{
thisLayer = "object not found";
thisTag = "object not found";
}


if (HighLogic.LoadedSceneIsFlight)
{


_gameObject = this.part.FindModelTransform(objectName).gameObject;
if (_gameObject != null)
{
Debug.LogWarning("Layer is:" + _gameObject.layer);
Debug.LogWarning("Tag is" + _gameObject.tag);
}
else
Debug.LogError("object not found");
}
}
}
}


MODULE
{
name = LayerFinder
objectName = BayDoorL1
}

License: CC0

It will spit the layer for the named GameObject out to the log, as well as the GUI menu.

Edited by lo-fi
Updated source
Link to comment
Share on other sites

Yes, in so far as it's applied to the gameobject that has the mesh collider component applied, which also happens to be the mesh itself. There are some confusing artefacts from the .mu > .mu import process that threw me a little to start with, so ignore comments about the collider object not being present.

I was going to message you, as this will no doubt be useful for your Skylon; you've ninja'd me rather successfully ;) Just posted a thread in add-on dev I was going to put forward for submission to your modding links too.

Link to comment
Share on other sites

  • 1 year later...

I hope it's okay to resurrect an old thread, but this is the closest I've found to an answer to the question NecroBones asks. I'm also trying to make a cargo bay part, and I have animations and collision meshes and all of that working, and want to disallow attachment to the doors.

I don't quite understand the answer given, however. I've successfully made animated parts so I thought I understood more or less what goes into the models and configs, but I've not run into the issue of tags, so I'm not clear on what I am meant to do. I'd really appreciate it if someone could nudge me in the right direction. 

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