Advertisement

Vehicle Steering

Started by January 19, 2016 10:45 PM
12 comments, last by Medo Mex 8 years, 7 months ago
@GuyWithBeard: Here is what I tried (but it doesn't work):

D3DXMatrixInverse(&VehicleWorldMatrixInversed, NULL, &VehicleWorldMatrix);

D3DXVECTOR3 TransformedCharacterPosition;
D3DXVec3TransformCoord(&TransformedCharacterPosition, &PlayerPosition, &VehicleWorldMatrixInversed);
D3DXVec3Normalize(&TransformedCharacterPosition, &TransformedCharacterPosition);

Up.

Any idea what's wrong with the above code?

Advertisement

@GuyWithBeard: Here is what I tried (but it doesn't work):

D3DXMatrixInverse(&VehicleWorldMatrixInversed, NULL, &VehicleWorldMatrix);

D3DXVECTOR3 TransformedCharacterPosition;
D3DXVec3TransformCoord(&TransformedCharacterPosition, &PlayerPosition, &VehicleWorldMatrixInversed);
D3DXVec3Normalize(&TransformedCharacterPosition, &TransformedCharacterPosition);

Not sure why normalize it at the end. After you've transformed it, player coordinates are now local space of the car, so Y or Z value (which ever is horizontal axis in your case) tells you on which side character is.

@BoredEngineer: Actually what I can use is the value of X not Y, and there is no value for Z

Now, if x > 0, the character on the right, if x < 0, the character on the left.

This topic is closed to new replies.

Advertisement