現在敵1 player1でLを押したらロックオンをするようにしています
下記はCameraUpdate内のプログラムです
いろいろなサイトをみてやってみたのですがうまくいきません
なにかヒントでもあれば教えていただきたいです
m_lookAt = (m_front * LOOKATRANGE) + m_pos;
this->UpdateView();
m_pos.m128_f32[0] = m_lookAt.m128_f32[0] - m_front.m128_f32[0] * LOOKATRANGE;
m_pos.m128_f32[1] = m_lookAt.m128_f32[1] - m_front.m128_f32[1] * LOOKATRANGE;
m_pos.m128_f32[2] = m_lookAt.m128_f32[2] - m_front.m128_f32[2] * LOOKATRANGE;
//注視転回点するでござる
if (CKeyInput::GetKeyPress('Q')) {
m_roteAngle -= 0.05;
CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->angle -= 0.05f;
m_roteMat = XMMatrixRotationY(m_roteAngle);
m_SubstitutePos = XMVector3TransformCoord(m_SubstitutePos, m_roteMat);
m_front = XMVector3TransformNormal(m_front, m_roteMat);
m_right = XMVector3Cross(m_front, m_eye_up);
}
if (CKeyInput::GetKeyPress('E')) {
m_roteAngle += 0.05;
CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->angle += 0.05f;
m_roteMat = XMMatrixRotationY(m_roteAngle);
m_SubstitutePos = XMVector3TransformCoord(m_SubstitutePos, m_roteMat);
m_front = XMVector3TransformNormal(m_front, m_roteMat);
m_right = XMVector3Cross(m_front, m_eye_up);
}
if (CKeyInput::GetKeyPress('K')) {
m_LockOn = true;
}
if (CKeyInput::GetKeyPress('J')) {
m_LockOn = false;
}
XMVECTOR targetVec = XMVectorSet(0,0,0,1);
if (m_LockOn) {
CGolem* enemy;
enemy = CScene::m_pLibMgr->m_pObjMgr->GetGameObject<CGolem>();
CPlayer *player;
player = CScene::m_pLibMgr->m_pObjMgr->GetGameObject<CPlayer>();
targetVec = enemy->m_pMyModel->m_pos - player->m_pMyModel->m_pos;
targetVec = XMVector3Normalize(targetVec);
//angle = atan2(targetVec.m128_f32[0], targetVec.m128_f32[2]) + PI;
//mat = XMMatrixRotationY(angle);
//targetVec = XMVector3TransformCoord(targetVec, mat);
}
//if (!m_LockOn) {
m_pos.m128_f32[0] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[0] + m_SubstitutePos.m128_f32[0] + targetVec.m128_f32[0];
m_pos.m128_f32[1] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[1] + m_SubstitutePos.m128_f32[1];
m_pos.m128_f32[2] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[2] + m_SubstitutePos.m128_f32[2] + targetVec.m128_f32[2];
//}
/*else {
m_pos.m128_f32[0] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[0] - targetVec.m128_f32[0];
m_pos.m128_f32[1] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[1];
m_pos.m128_f32[2] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[2] - targetVec.m128_f32[2];
}*/
m_lookAt.m128_f32[0] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[0] + targetVec.m128_f32[0];
m_lookAt.m128_f32[1] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[1];
m_lookAt.m128_f32[2] = CScene::m_pLibMgr->m_pObjMgr->GetPlayer()->m_pos.m128_f32[2] + targetVec.m128_f32[2];
m_roteAngle = 0.0f;