Search the Community
Showing results for tags 'collision detection'.
-
c++ [SOLVED] PhysicalTrigger won't trigger, what am I missing?
kbrodie posted a topic in C++ Programming
I am trying to get a vehicle to interact with a physical trigger in the world, but the objects don't interact and no callback is ever called. For creating the physical trigger I use the following code: //Create a box-shaped trigger, with size 0. m_physical = Unigine::PhysicalTrigger::create(3, Unigine::Math::vec3()); m_physical->setVisible(true); m_physical->setEnabled(true); m_physical->setCollisionMask(-1); m_physical->setPhysicalMask(-1); m_physical->setExclusionMask(0); m_physical->setEnterCallback(new cHitCallback(this)); Elsewhere in the code, the size, location and rotation is set. To make sure that the trigger is at the expected place, I draw it on screen with with the following code: Unigine::Visualizer::get()->renderSolidBox(m_physical->getSize(), m_physical->getWorldTransform(), m_color); The vehicle has a body and shape created like this: Unigine::ObjectPtr body = Unigine::Object::cast (m_body_node->getReference()) ; m_rigidBody = Unigine::BodyRigid::create(); m_boxShape = Unigine::ShapeBox::create(Unigine::Math::vec3(4.78, 2.52, 3.10)); m_boxShape->setCollisionMask(-1); m_boxShape->setExclusionMask(0); m_boxShape->setEnabled(1); m_rigidBody->addShape(m_boxShape->getShape()); m_rigidBody->setPhysicalMask(-1); m_rigidBody->setEnabled(1); body->setBody(m_rigidBody->getBody()); For testing purposes, I used the following line to visualize the shape of my vehicle: Unigine::Visualizer::get()->renderBox(m_boxShape->getSize(), m_rigidBody->getTransform(), Unigine::Math::vec4(0, 0, 1.0, 1.0)); I have placed a break point in the callbackmethod "void run(Unigine::Ptr<Unigine::Body> body)" of the cHitCallback class, to make sure that the callback is infact called. The break point is never triggered. Did I miss something here? Please help me out.