Search the Community
Showing results for tags 'addcontactcallback'.
-
[SOLVED] How to set rigid body of the node for collision(node is created by noderef)
burakdogancay posted a topic in C++ Programming
I am trying to add collision process for nodes.I already created contactcallback for intersection and it works like charm when i implement it directly to editor with calling by function in c++.So it directly detect intersection and collision wit contact callback function. I would like to explain it with code; It works correctly with this way Unigine::NodePtr mObject1; Unigine::NodePtr mObject1parent; mObject1parent = Util::Search::getNodeRecursive("Objectparent", mReference->getNode()); mObject1 = Util::Search::getNodeRecursive("mObject1",mObject1parent); //I already added rigid body for object in unigine editor. mObject1->getObjectBodyRigid()->getBody()->addContactCallback(Unigine::MakeCallback(this,contact_callback));//contact callback function detects intersections for collision But I would like to remove Object1 from editor and add it dynamically with code. Unigine::NodePtr mObject1; Unigine::NodePtr mObject1parent; mObject1parent = Util::Search::getNodeRecursive("Objectparent", mReference->getNode()); mObject1 = Util::Search::getNodeRecursive("mObject1",mObject1parent); //I disabled object1 from editor(something like removeving from editor) //Then i added and created this object dynamically with below code: Unigine::NodeReferencePtr tObject1 = Unigine::NodeReference::create("External/Entities/Object1.node");//this nodereference has node with rigid body inside tObject1->release(); Unigine::Editor::get()->addNode(tObject1->getNode(),1); mObject1= tObject1->getNode(); mObject1->setWorldPosition(mObject1parent->getWorldPosition()); mObject1->setWorldRotation(mObject1parent->getWorldRotation()); //But unfortunately it does not get this Object1 node for collision, so below command gets trouble if we call rigid body of this node //Basically it acts like this node is not exists.But i can set its position and direction and even i can move it in any axis. mObject1->getObjectBodyRigid()->getBody()->addContactCallback(Unigine::MakeCallback(this,contact_callback)); Any help will be appreciated.- 4 replies
-
- collision
- addcontactcallback
-
(and 2 more)
Tagged with: