From e49a41567130b7eebcc7a35e706200ba68c63739 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 1 Feb 2008 13:34:50 +0000 Subject: [PATCH] Try to making the homing missiles turn more smoothly. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1434 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/homingmissile.projectile | 2 +- src/homing.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data/homingmissile.projectile b/data/homingmissile.projectile index 8edd69f30..93662660f 100644 --- a/data/homingmissile.projectile +++ b/data/homingmissile.projectile @@ -9,7 +9,7 @@ (max-height 1.0) (force-updown 25.0) ;; force raising/lowering the homing missile if it's too low/high (max-distance 20.0) ;; maximum distance at which a kart is still followed - (max-turn-angle 5.0) ;; maximum turn angle when following a kart + (max-turn-angle 65.0) ;; maximum turn angle when following a kart ) ;; EOF ;; diff --git a/src/homing.cpp b/src/homing.cpp index ee587e5e1..df1f97c60 100644 --- a/src/homing.cpp +++ b/src/homing.cpp @@ -77,6 +77,12 @@ void Homing::update(float dt) if(fabsf(steer)>90.0f) steer=0.0f; if(steer<-m_st_max_turn_angle) steer = -m_st_max_turn_angle; if(steer> m_st_max_turn_angle) steer = m_st_max_turn_angle; + // The steering must be interpreted as grad/s (otherwise this would + // depend on the frame rate). But this would usually miss the karts, + // since the angle isn't adjusted quickly enough when coming closer + // So we allow for (much) larger steering angles the closer the + // kart is by multiplying the rotation/sec with max_distance/minDistance + steer *=(dt*m_st_max_distance/minDistance); btMatrix3x3 steerMatrix(btQuaternion(0.0f,0.0f,DEGREE_TO_RAD(steer))); my_trans.setBasis(my_trans.getBasis()*steerMatrix); } // minDistance