fred.naar Posted July 26, 2020 Share Posted July 26, 2020 Hello I have a node within a node hierarchy and I am trying to unparent it by setting Node.SetWorldParent(null) My goal is to have the separated node stay in position and not following the parent node. If I debug such node Parent is null but node keeps on moving as if attached to parent Am i missing something ? thanks Fred Link to comment
jaaaaa Posted July 27, 2020 Share Posted July 27, 2020 (edited) There is another function Node.setParent(), did you try it with this? Greetings Edited July 27, 2020 by ipg_jallmenroeder Link to comment
fred.naar Posted July 27, 2020 Author Share Posted July 27, 2020 yes I tried both...thanks Link to comment
morbid Posted July 27, 2020 Share Posted July 27, 2020 Hello Fred, Is it C# or C++? Because of capitalizing I thought it's a C#. Anyway, this method works as expected with both. I tried the simplest way: C# component: private void Init() { // write here code to be called on component initialization Node node = World.GetNodeByName("Sphere"); //It's a parent Node node2 = World.GetNodeByName("Cuboid"); node2.SetWorldParent(null); //Commenting this line causes both nodes to move as expected } private void Update() { node.WorldTranslate(0.0f, 0.1f, 0.0f); // Here I move the parent along Y axis } Almost same code in C++: Unigine::NodePtr node1; Unigine::NodePtr node2; AppWorldLogic::AppWorldLogic() {} AppWorldLogic::~AppWorldLogic() {} int AppWorldLogic::init() { node1 = World::getNodeByName("material_ball"); //Parent node node2 = World::getNodeByName("Cuboid"); node2->setWorldParent(nullptr); return 1; } int AppWorldLogic::update() { node1->worldTranslate(0.0f, 0.1f, 0.0f); return 1; } Could you please share a sample with your code? Thanks. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
fred.naar Posted July 27, 2020 Author Share Posted July 27, 2020 (edited) Solved, sorry it was my mistake I had to unparent the player not the node itself... thanks for the quick response! Fred Edited July 27, 2020 by fred.naar Link to comment
Recommended Posts