Jump to content

Anyone got the new 0.20 attachment nodes working yet?


Razchek

Recommended Posts

[RESOLVED] Sort-of. The nodes themselves are broken.

Construct your attach nodes as follows:


NODE
{
name = top
transform = myTransform
size = 1 // this is not used - ksp bug.
method = FIXED_JOINT // this is not used - ksp bug.
}

Make sure the transform is a child of the part-tools game object and that the transform has the blue arrow (Z) pointing down away from the attach point. I.e. Down if you place it at the top of a model.

---- Resolved, the post below is the original post ----

I've been playing around with the new attach method but have yet to get the node in-game.

Commenting out the old attach code and trying the new stuff is not working.


// --- node definitions ---
// definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z
//node_stack_top = 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 2
//node_stack_bottom = 0.0, -0.5, 0.0, 0.0, 1.0, 0.0, 2
ATTACH
{
name = top
transformName = topNodeTransform
}

The hierarchy in Unity:

PartTools Object
|- myPartModel
|-- myPartMeshes
|-- ...
|- topNodeTransform

I've also tried making the transform a child of the mesh:

PartTools Object
|- myPartModel
|-- myPartMeshes
|-- ...
|-- topNodeTransform

The empty GameObject that I'm using for the transform has been tried with all axis facing 'up' (and of course positioned at the top of the model).

I've tried tagging the transform on a couple of different layers with no luck.

Anyone else had any success? :)

Edited by Razchek
Link to comment
Share on other sites

Try "transform" instead of "transformName" (Calling "Part.AddAttachNode(null)" returned:

Part: Cannot add attach node. Node requires a 'name' value.

Part: Cannot add attach node. Node requires a 'transform' value.

Part: Cannot add attach node. Transform of name ''

Still, this doesn't seem to be called OnAwake (I should see an error in the DebugLog).... hence try this:

[KSPAddon(KSPAddon.Startup.MainMenu, false)]
public class thingy : UnityEngine.MonoBehaviour {
private static bool initKerbal = false;

public void Update() {
if (initKerbal == false) {
initKerbal = true;

ConfigNode hi = new ConfigNode("Attach");
hi.AddValue("name","top");
hi.AddValue("transform","topNodeTransform");
PartLoader.getPartInfoByName("mk1pod").partPrefab.AddAttachNode(hi);
}
}
}

*** I don't have all that modeling stuff (and really don't want it), so I don't have something I can test on.

Link to comment
Share on other sites

I decided to take another whack at it and figured it out..

Construct your 'attachment' nodes like this:

NODE
{
name = top
transform = topTransform // Or whatever your transform name is.
}

Size and Method are not being respected, so they will just be place-holders until it's fixed in the AttachNode class.

--edit

Should have edited previous post, sorry.

Edited by Razchek
Link to comment
Share on other sites

Was there anything special that needed to be done to the game object in unity for it to work aside of having the name correct?

Make sure the transform is a child of the part-tools gameobject and that the transform has the blue arrow (Z) pointing down away from the attach point. I.e. Down if you place it at the top of a model.

Don't expect the new nodes to work properly yet though, there are other problems with the nodes it seems. :(

For one, both size & method fields are not used. Size is always 0, method is always FIXED_JOINT.

Edited by Razchek
Link to comment
Share on other sites

Make sure the transform is a child of the part-tools gameobject and that the transform has the blue arrow (Z) pointing down away from the attach point. I.e. Down if you place it at the top of a model.

Don't expect the new nodes to work properly yet though, there are other problems with the nodes it seems. :(

For one, both size & method fields are not used. Size is always 0, method is always FIXED_JOINT.

Ahhhh. The arrow pointing down. That was the trick. I had the node code figured out already I just didn't have the silly arrow pointed in the right way. It was late last night when I was going through this and must have forgotten to try pointing the arrow down. :/

Link to comment
Share on other sites

Looking at the code I think 'method' is in being passed correctly. I still have no idea what the methods actually do though.

I first tested it with a plugin, the method parameter is not used in-game. -snip-

The method field determines how the physics will handle the connected part relative to the joint, I think. :)

FIXED_JOINT, // Standard stacking attachment
HINGE_JOINT, // Standard surface attachment
LOCKED_JOINT,
MERGED_PHYSICS,
NO_PHYSICS,
NONE

Edited by Razchek
Link to comment
Share on other sites

I first tested it with a plugin, the method parameter is not used in-game. Later checking the code proved it.

If you look at the AttachNode class initializer overload with params you will see before the method returns the code just assigns "FIXED_JOINT" to the method parameter, the original param never leaves the method scope and doesn't get assigned to the public field. :(

The method field determines how the physics will handle the connected part relative to the joint, I think. :)

FIXED_JOINT, // Standard stacking attachment
HINGE_JOINT, // Standard surface attachment
LOCKED_JOINT,
MERGED_PHYSICS,
NO_PHYSICS,
NONE

Yup. You are correct. I completely missed that part. I guess that's why it doesn't work because it snuck past someone else. ;)

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

I think that this is the place to find some solutions for the problems I am experiencing. I and writing a part that I hope will have multiple surface attachment nodes. Indeed I hope it will have a variable number of these. I had planned to just make a call to AddAttachNode, but the config to pass to it is proving to be a bit tricky. In particular I get errors about the transform. Do I have to define the transform in unity, or is there a way that I can define / create it and use it on the fly to created multiple attachment nodes is various locations at runtime?

Thanks in advance :)

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