burakdogancay Posted August 9, 2019 Share Posted August 9, 2019 (edited) How to know direction of object parent to move object along its forward.Is there any way to get related parent forward direction in Unigine? For example if i move the turret according to given rotation and its child object available on it, so how can i move this object along to turrets forward direction.The most important point is; i can not change its x,y and z axis with set position function, it should move without giving its x,y or z axis accordig to forward direction of the turret. Example code; float objectifps; const float mObjectMovSpeed = 3.0f; float mforward_direction = Unigine::Math::Vec3(0.0f, -1.0f, 0.0f); // it moves on y direction with this vector, but i want to move it according to head of turret direction. mmissileifps = 0.05; mObjectLeft->setWorldPosition(mObjectLeft->getWorldPosition()+mforward_direction*mObjectMovSpeed*objectifps); İt moves along y axis, i couldn't manage objects movement according to direction of turret head. Edited August 9, 2019 by burakdogancay Link to comment
cash-metall Posted August 12, 2019 Share Posted August 12, 2019 try something like this NodePtr mObjectLeft = .....; // original node NodePtr parent = mObjectLeft->getParent(); if (parent) { vec3 mforward_direction = parent->getWorldDirection(Math::AXIS_Y); mObjectLeft->setWorldPosition(mObjectLeft->getWorldPosition() + mforward_direction * mObjectMovSpeed * Game::get()->getIFps()); } Link to comment
burakdogancay Posted August 19, 2019 Author Share Posted August 19, 2019 Thank you so much it woks well Link to comment
Recommended Posts