make calcangle actually work

This commit is contained in:
2023-12-05 12:45:49 -05:00
parent 278b06b321
commit 1cf1e11d4f
2 changed files with 4 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ namespace math {
Angle calcAngle(Position sP, Position eP) {
Angle returned;
returned.x = -(asinf((eP.y - sP.y) / distance(sP, eP)) * 180.0f / M_PI);
returned.y = -(atan2f(eP.x - sP.x, eP.z - sP.z) / M_PI * 180.0f + 180.0f);
returned.y = (atan2f(eP.x - sP.x,eP.z - sP.z) / M_PI * 180.0f);
return returned;
}

View File

@@ -36,9 +36,10 @@ public:
if (cameraMode == CameraMode::THIRD_PERSON) {
std::cout << "Calculated Pitch: " << math::calcAngle(position,getPlayer()->position).x << " Calculated Yaw: " << math::calcAngle(position,getPlayer()->position).y << std::endl;
//this->position = getPlayer()->cameraPoint(2);
this->position = getPlayer()->cameraPoint(2);
this->position.y += 0.5;
this->angle.x = math::calcAngle(position,getPlayer()->position).x;
//this->angle.y = math::calcAngle(position,getPlayer()->position).y;
this->angle.y = math::calcAngle(position,getPlayer()->position).y;
}
//if (engine->frameCount == 5000)