I want to move a character in a matrix

21 Views Asked by At

I want the object to move in the direction of the rotation axis. And we want the rotation axis to rotate while its position is fixed.

Taking a game character as an example, the character can rotate in place and move forward.

This is an example picture.

enter image description here

How should I implement this as a matrix?

I calculated it like this:

// rotarion
D3DXMatrixRotationYawPitchRoll(&tempRotation, 0.0f, 0.0f, 0.0f + (rotationX));

// move
D3DXMatrixTranslation(&tempMove, moveX, 0.0f, 0.0f);

// move * rotarion
D3DXMatrixMultiply(&tempTM1, &tempMove, &tempRotation);

I know that's the wrong way to do it.

Because it rotates after movement, it can move to the rotated location, but its location continues to change when it rotates.

But I don't know how to solve it.

How do I calculate it to get the desired value?

I am using direct3D.

0

There are 0 best solutions below