How would i make an object rendering move in a cirlcle, right now i have a lazer which is a box moving up and down and when the camera look vector touches it , it speeds up
void Lazer::UpdateLazer(float dt)
{
LazerPos = LazerPos + LazerDir * speed *dt;
D3DXMatrixTranslation(&matTrans, LazerPos.x, LazerPos.y, LazerPos.z);
if (LazerPos.y > 200.0f)
{
LazerDir.y = -1.0f;
}
if (LazerPos.y < 100.0f)
{
LazerDir.y = 1.0f;
}
D3DXMatrixInverse(&ObjMatrix, NULL, &matTrans);
D3DXVec3TransformCoord(&newPos, &gCamera->pos(), &(ObjMatrix));
D3DXVec3TransformNormal(&newDir, &gCamera->look(), &(ObjMatrix));
D3DXIntersect(Box, &newPos, &newDir, &hit, NULL, NULL, NULL, NULL, NULL,NULL);
if (hit)
{
speed += 1.0f;
}
else
{
speed -= 0.001f;
}
}