mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Only face target when in combat, not when selecting friendly NPCs
This commit is contained in:
parent
e234ac8d7a
commit
05870c1f03
3 changed files with 5 additions and 3 deletions
|
|
@ -120,6 +120,7 @@ public:
|
|||
|
||||
// Targeting support
|
||||
void setTargetPosition(const glm::vec3* pos);
|
||||
void setInCombat(bool combat) { inCombat_ = combat; }
|
||||
bool isMoving() const;
|
||||
void triggerMeleeSwing();
|
||||
void setEquippedWeaponType(uint32_t inventoryType) { equippedWeaponInvType_ = inventoryType; meleeAnimId = 0; }
|
||||
|
|
@ -228,6 +229,7 @@ private:
|
|||
|
||||
// Target facing
|
||||
const glm::vec3* targetPosition = nullptr;
|
||||
bool inCombat_ = false;
|
||||
|
||||
// Selection circle rendering
|
||||
uint32_t selCircleVAO = 0;
|
||||
|
|
|
|||
|
|
@ -872,12 +872,11 @@ void Renderer::update(float deltaTime) {
|
|||
// Movement-facing comes from camera controller and is decoupled from LMB orbit.
|
||||
if (cameraController->isMoving() || cameraController->isRightMouseHeld()) {
|
||||
characterYaw = cameraController->getFacingYaw();
|
||||
} else if (targetPosition && !emoteActive && !cameraController->isMoving()) {
|
||||
// Face target when idle
|
||||
} else if (inCombat_ && targetPosition && !emoteActive) {
|
||||
// Face target when in combat and idle
|
||||
glm::vec3 toTarget = *targetPosition - characterPosition;
|
||||
if (glm::length(glm::vec2(toTarget.x, toTarget.y)) > 0.1f) {
|
||||
float targetYaw = glm::degrees(std::atan2(toTarget.y, toTarget.x));
|
||||
// Smooth rotation toward target
|
||||
float diff = targetYaw - characterYaw;
|
||||
while (diff > 180.0f) diff -= 360.0f;
|
||||
while (diff < -180.0f) diff += 360.0f;
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ void GameScreen::render(game::GameHandler& gameHandler) {
|
|||
// Update renderer face-target position and selection circle
|
||||
auto* renderer = core::Application::getInstance().getRenderer();
|
||||
if (renderer) {
|
||||
renderer->setInCombat(gameHandler.isAutoAttacking());
|
||||
static glm::vec3 targetGLPos;
|
||||
if (gameHandler.hasTarget()) {
|
||||
auto target = gameHandler.getTarget();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue