Knowledge Base » How to link a bone to a Model

The Untold Engine allows a model to follow the armature of another model. For example, let's say you want the gun to follow the hand bone of the astronaut.

Image

To do so, you can get the bone's Rest Pose Space by using the method shown in line 2. Once you obtain the pose space, then you can apply it to the gun as shown in line 3.

//declare matrix for the gun space
U4DEngine::U4DMatrix4n m;

//2. Get the bone rest pose space        
if(astronaut->getBoneRestPose("hand.r",m)){

//3. Apply space to gun
gun->setLocalSpace(m);

}

You can also link an object to a bone while an animation is running. The snippet below shows how to do so:

//declare matrix for the gun space
U4DEngine::U4DMatrix4n m;

//2. Get the bone animation "runningAnimation" pose space
if(getBoneAnimationPose("hand.r",runningAnimation,m)){

//3. Apply space to gun
gun->setLocalSpace(m);
    
}

This will allow the illustion that astronaut is holding the gun.

Image