YouDoNotKnowMyName Posted December 25, 2021 Share Posted December 25, 2021 Good afternoon everybody! Is it possible to "ref attach" a static object to another with a script? So that if one moves, the thing that is "ref attached" to it will also move. And is there a way to un-ref-attach two object with a script so they can move freely again? Link to comment Share on other sites More sharing options...
niston Posted December 25, 2021 Share Posted December 25, 2021 Yes, it's possible: 1) PlaceAtNode() with the refattach parameter.2) AttachTo() "Unattaching" is not possible per se. But you can disable one object and then move it, the refattached stuff will NOT move with it while it's disabled. Take note that Refattach handling is extremely bugged in the engine. It's probably the most broken part of it all. A particular annoyance is that the game *sometimes* fails to preserve the position of refattached stuff upon save/reload. Things will go out of sync, and even detecting this condition (so that you can fix it) is a bit involved. It gets even worse when stuff is moving while unload/reload, so prevent that from happening whenever its possible. Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 25, 2021 Author Share Posted December 25, 2021 I already tried "AttachTo" and it did not work.The object moved, but the object that was "attached to it" did not move with it. So I will try the "PlacAtNode". Where will that place the object?At the "origin point" of the object that it gets attached to? Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 25, 2021 Author Share Posted December 25, 2021 Yes, it's possible: 1) PlaceAtNode() with the refattach parameter.2) AttachTo() "Unattaching" is not possible per se. But you can disable one object and then move it, the refattached stuff will NOT move with it while it's disabled.So, lets say I have two objects ObjectA and ObjectB ObjectB is attached to ObjectA. Now, I want to "unattach" ObjectB. I would disable ObjectB, move it and then re-enable it and it will be unattached? Link to comment Share on other sites More sharing options...
niston Posted December 25, 2021 Share Posted December 25, 2021 Oh yes.For it to work, the NIF you want to refattach TO needs to have a node in it called REF_ATTACH_NODE.Doesn't matter where that node is, but refattaching wont work without that. PlaceAtNode() will similarly place the object exactly at a Node's position inside the target NIF. You use the name of the node to identify it. It's a very powerful function that lets you place objects exactly where you want, with well defined rotation etc. Nifskope is your friend. Disabling/enabling will not make stuff unattached, but it allows you to move Object A without also moving Object B. You'll have to delete() the attached object to really break the refattach link. Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 25, 2021 Author Share Posted December 25, 2021 Oh yes.For it to work, the NIF you want to refattach TO needs to have a node in it called REF_ATTACH_NODE.Doesn't matter where that node is, but refattaching wont work without that. Nifskope is your friend.Ok, is there a tutorial for adding such a node? Link to comment Share on other sites More sharing options...
niston Posted December 25, 2021 Share Posted December 25, 2021 Dunno about a tutorial tbh. I can help you with it, but right now I have to get ready to meet family.Maybe tomorrow? Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted December 25, 2021 Author Share Posted December 25, 2021 Dunno about a tutorial tbh. I can help you with it, but right now I have to get ready to meet family.Maybe tomorrow?Sure, I have all the time in the world ... Merry christmas! Link to comment Share on other sites More sharing options...
niston Posted December 26, 2021 Share Posted December 26, 2021 So open the NIF you want stuff to attach TO in nifskope. Find the top node, 0 NiNode and right click it. Select Block>Insert from the menu.A new menu comes up, select NiNode from it. A new NiNode will appear at the bottom of the node tree.Click on the 0 NiNode at the top. In the list below the treeview, scroll down until you find "Children". Above is "Num Children" - increase the number by 1 by dblclicking and writing into the field.Also set the value of Flags to 14. Doubleclick the number and enter 14.Then click the green arrow symbol next to Children and expand the Children entry. Click on the + sign next to the entry that says None and enter the number of the NiNode you added before. Here, that would be 1.The NiNode in the treeview above will shift its position and appear as a child of the top NiNode. Select it. Then find in the list (block details) below the treeview the entry for "Name" and click on the "Txt" icon. Window pops up. Type "REF_ATTACH_NODE" and click OK: Now in the menu Spells, find Sanitize>Reorder Block and click that.Then save the NIF with teh save icon. Done. Link to comment Share on other sites More sharing options...
niston Posted December 26, 2021 Share Posted December 26, 2021 Now, if you want to make use of PlaceAtNode(), you can insert another NiNode in the same way you inserted the REF_ATTACH_NODE.But instead of calling it REF_ATTACH_NODE, call it whatever you want. A name indicative of it's intended function is recommended. Then, and this is the beauty of it, you can move the node to wherever you want in the nif.Use the Translation and Rotation properties of the Node to achieve this. These are in the list below the treeview, if you select your newly inserted node. When you use PlaceAtNode() with the name of the node you put into your nif, the object will spawn (with it's origin) at that node's exact location, using the node's rotation. I think (didn't try it so far) you can even use the Scale property of the node to scale the object that's being spawned at this node (beware - collision won't scale with it). The function also has a parameter to directly refattach the spawned object to the node. To avoid some of the looming headaches due to bugged refattach handling, delete any spawned objects on unload (unless they use power, then DONT delete them) and respawn them on load. Link to comment Share on other sites More sharing options...
Recommended Posts