Skip to content

Commit 7a57ac7

Browse files
committed
fix player rotation when aiming
1 parent 7c505c6 commit 7a57ac7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Server/Components/NPCs/NPC/npc.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,13 +1190,23 @@ void NPC::updateAimData(const Vector3& point, bool setAngle)
11901190
if (setAngle)
11911191
{
11921192
auto rotation = getRotation().ToEuler();
1193-
rotation.z = glm::degrees(glm::atan(unitVec.y, unitVec.x));
1193+
auto angle = glm::degrees(glm::atan(unitVec.y, unitVec.x)) + 270.0f;
1194+
if (angle >= 360.0f)
1195+
{
1196+
angle -= 360.0f;
1197+
}
1198+
else if (angle < 0.0f)
1199+
{
1200+
angle += 360.0f;
1201+
}
1202+
1203+
rotation.z = angle;
11941204
setRotation(rotation);
11951205
}
11961206

11971207
// Set the aim sync data
11981208
aimSync_.AimZ = aimZ;
1199-
aimSync_.CamFrontVector = camFronVector;
1209+
aimSync_.CamFrontVector = unitVec;
12001210
aimSync_.CamPos = camPosition;
12011211

12021212
// set the flags

0 commit comments

Comments
 (0)