Search the Community
Showing results for tags 'hierarchy'.
-
I have a part that has specific attach node IDs. I want to grab all the child parts of the attachNodes which have that ID. However, when using Part.findAttachNodes("theID"), though the method does return an array of the right attach nodes, when I try to access the attachNode attachedPart method, to access the child parts, the parts come back with the same reference. When I look at the part.instanceId, the instance IDs are repeated. I've tried just about every way I can think of to access the child parts,but to no avail. Very mysterious... Here's my code. public List<Part> childParts; public getParts() { foreach(AttachNode an in part.findAttachNodes(nodeID) { childParts.Add(an.attachedPart); } } Public rotateParts() { foreach(Part p in childParts) { p.partTransform.findChild("model).RotateAround(transform.position, transform.up, 25 * TimeWarp.deltaTime); if(p.partInfo.internalConfig.hasData) { p.internalModel.transform.RotateAround.transform.position, transform.forward, 25 * TimeWarp.fixedDeltaTime * -1); } } } public override void OnStart(PartModule.StartState state) { if(!HighLogic.loadedSceneIsFlight)return; childParts = new List<Part>(); } public void FixedUpdate() { rotateParts(); } EDIT: So, after more, testing (practically ripped my hair out!), I discovered there was nothing wrong with the code, the problem was how the nodes were defined in the cfg file. Original CFG: node_stack_top = 0.0, 2.8152, 0.00, 0.0, 1.0, 0.0, 3 node_stack_side_1 = 2.8152, 0.0, 0.0, 1.0, 0.0, 0.0, 3 node_stack_side_2 = -2.8152, 0.0, 0.0, -1.0, 0.0, 0.0, 3 node_stack_side_3 = 0.0, 0.0, 2.8152, 0.0, 0.0, 1.0, 3 node_stack_side_4 = 0.0, 0.0, -2.8152, 0.0, 0.0, -1.0, 3 node_stack_bottom = 0.0, -2.8152, 0.00, 0.0, -1.0, 0.0, 3 Fixed CFG: node_stack_top = 0.0, 2.8152, 0.00, 0.0, 1.0, 0.0, 3 node_stack_side1 = 2.8152, 0.0, 0.0, 1.0, 0.0, 0.0, 3 node_stack_side2 = -2.8152, 0.0, 0.0, -1.0, 0.0, 0.0, 3 node_stack_side3 = 0.0, 0.0, 2.8152, 0.0, 0.0, 1.0, 3 node_stack_side4 = 0.0, 0.0, -2.8152, 0.0, 0.0, -1.0, 3 node_stack_bottom = 0.0, -2.8152, 0.00, 0.0, -1.0, 0.0, 3 I looked at how the nodes were defined in Squad's station hub part. Each node was defined uniquely as right, left, back, front and so forth. Apparently, when the config nodes are loaded from the attachNode definition in the cfg, the underscores are stripped out, consequently the values in AttachNodes list were overwritten, although partjoints were still created and the parts were attached.