From aeda9d6b87e31154751d9abe03bdfa941a081f69 Mon Sep 17 00:00:00 2001 From: iAmir Date: Wed, 24 Apr 2024 04:39:30 +0330 Subject: [PATCH] another attempt to fix npc movements --- Server/Components/NPCs/NPC/npc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/Components/NPCs/NPC/npc.cpp b/Server/Components/NPCs/NPC/npc.cpp index 206bc5a45..99e799b34 100644 --- a/Server/Components/NPCs/NPC/npc.cpp +++ b/Server/Components/NPCs/NPC/npc.cpp @@ -164,7 +164,7 @@ bool NPC::move(Vector3 pos, NPCMoveType moveType) if (!(std::fabs(glm::length(velocity_)) < DBL_EPSILON)) { - estimatedArrivalTimeNS_ = Time::now().time_since_epoch().count() + (static_cast(distance / glm::length(velocity_)) * ((npcComponent_->getFootSyncRate() * 10000) + 1000000)); + estimatedArrivalTimeNS_ = Time::now().time_since_epoch().count() + (static_cast(distance / glm::length(velocity_)) * (/* (npcComponent_->getFootSyncRate() * 10000) +*/ 1000000)); } else { @@ -228,10 +228,11 @@ void NPC::advance(TimePoint now) { auto position = getPosition(); - if (estimatedArrivalTimeNS_ <= Time::now().time_since_epoch().count()) + if (estimatedArrivalTimeNS_ <= Time::now().time_since_epoch().count() || glm::distance(position, targetPosition_) <= 0.1f) { - footSync_.Position = targetPosition_; + auto pos = targetPosition_; stopMove(); + setPosition(pos); npcComponent_->getEventDispatcher_internal().dispatch(&NPCEventHandler::onNPCFinishMove, *this); } else