From 6f67fd6507199500bf064877e8404725bbf2d9e9 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 26 Sep 2016 12:46:44 +0800 Subject: [PATCH] Make swatter be able to swat in any direction --- src/items/swatter.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index 51940ddc5..41803c972 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -280,13 +280,11 @@ void Swatter::pointToTarget() } else { - Vec3 swatter_to_target = m_target->getXYZ() - -Vec3(m_scene_node->getAbsolutePosition()); + Vec3 swatter_to_target = + m_kart->getTrans().inverse()(m_target->getXYZ()); float dy = -swatter_to_target.getZ(); float dx = swatter_to_target.getX(); - float angle = SWAT_ANGLE_OFFSET + (atan2(dy, dx)-m_kart->getHeading()) - * 180.0f/M_PI; - + float angle = SWAT_ANGLE_OFFSET + atan2f(dy, dx) * 180 / M_PI; m_scene_node->setRotation(core::vector3df(0.0, angle, 0.0)); } } // pointToTarget