DirectX12 development, character steering problem

11 Views Asked by At

I need the character to simulate people's normal turning effect, but now the character is orbiting around the center of a circle.

enter image description here

How should I do it so that the character can only make a small turn according to the angle?

            double molecule = x * mLastMousePos.x + y * mLastMousePos.y;
            double denominator = sqrt(x * x + y * y) * sqrt(mLastMousePos.x * mLastMousePos.x + mLastMousePos.y * mLastMousePos.y);
            double cos_angle = molecule / denominator;
            double angle = acos((float)cos_angle) * 180 / 3.1415926;
            int i = 0;
            for (i = 0; i < mSkinned.size(); i++) {
                XMMATRIX rotation = XMMatrixRotationY(-angle);
                XMStoreFloat4x4(&mSkinned[i]->World, 
XMMatrixMultiply(XMLoadFloat4x4(&mSkinned[i]->World), rotation));
                mSkinned[i]->NumFramesDirty = gNumFrameResources;           
            }
        }
0

There are 0 best solutions below