From 372b62566b15bbcf79e3320d6daf751e04b7e501 Mon Sep 17 00:00:00 2001 From: fisted Date: Tue, 18 Jan 2011 06:50:24 +0100 Subject: fixed tower bug --- src/game/gamecore.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/game/gamecore.cpp') diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index c3c29537..629b32e8 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -320,13 +320,15 @@ void CCharacterCore::Tick(bool UseInput) if(d < PhysSize*1.25f && d > 1.0f) { float a = (PhysSize*1.45f - d); - + float v = 0.5f; + // make sure that we don't add excess force by checking the - // direction against the current velocity - vec2 VelDir = normalize(m_Vel); - float v = 1-(dot(VelDir, Dir)+1)/2; - m_Vel = m_Vel + Dir*a*(v*0.75f); - m_Vel = m_Vel * 0.85f; + // direction against the current velocity. if not zero. + if (length(m_Vel) > 0.0001) + v = 1-(dot(normalize(m_Vel), Dir)+1)/2; + + m_Vel += Dir*a*(v*0.75f); + m_Vel *= 0.85f; } // handle hook influence -- cgit 1.4.1