CFuncMoveLinear Fix
Jump to navigation
Jump to search
This is a fix for the func_movelinear entity, specifically when parenting it to something else.


func_movelinear.cpp
Lines 86-88 (87-89 in the OB code) in func_movelinear.cpp look like this:
m_vecPosition1 = GetAbsOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition);
m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance);
m_vecFinalDest = GetAbsOrigin();
Change them to look like this:
m_vecPosition1 = GetLocalOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition);
m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance);
m_vecFinalDest = GetLocalOrigin();
Originally, the start & end positions would be calculated in absolute (world) space. These positions never move (even if the entity's parent does), and can cause movement problems. The start & end positions are now calculated in local (parent) space. Thus, when the parent moves, the entity will also move properly.