I'm using this code for my Entity class:
void Entity::Face(FXMVECTOR target)
{
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
up = XMVector3Transform(up, Rotation);
Rotation = XMMatrixLookAtLH(Translation, target, up); //Rotation is a XMMATRIX, Translation is a XMVECTOR
}
And trying to get it to face another entity.Basically I'm doing this:
Entity a = //....
Entity b = //.......
a.Face(b.Translation);
And what happens is one of 3 things: 1.The function crashes, because of an assertion 2.Entity 'a' is misplaced in a weird position 3.Entity 'a' dissapears
This damn function XMMatrixLookAtLH has been the source of problems all over my project, everywhere I used it I had to spend hours to get it to work properly.
If I create the rotation matrix with XMMatrixRotationRollPitchYawFromVector, it works perfectly, however I NEED to get it to face directly at the point it's been given and I don't know how to get it to work.Please someone give me an advice.