Topic: How to parent object to bone in C++?

I have tried in several ways to link an object to a bone (for example, to match a weapon to the hand of a character) but I have had difficulties with the transformations and I have not been able to solve them

Re: How to parent object to bone in C++?

I have solved it, adding this code in the update function:

MOEntity * weapon = scene->getEntityByName("star");
MOEntity * keyla = scene->getEntityByName("ky"); 
MOBone * bone = keyla->getMesh()->getArmature()->getBoneByName("IK.hand.R");
        
weapon->setPosition(  keyla->getTransformedVector( bone->getTransformedPosition() ) );
weapon->setEulerRotation(   bone->getEulerRotation() + keyla->getEulerRotation() );

Last edited by ArielRiv (2017-05-24 07:53:30)