Func_movelinear fixes

► Fixed position calculations in CFuncMoveLinear by replacing GetAbsOrigin() with GetLocalOrigin(). This ensures movement positions are correctly calculated relative to the entity’s local origin, preventing issues with parented entities.
► Added UpdateMoveSound() function to dynamically handle movement sound playback. This function adjusts the pitch based on speed and ensures proper start/stop behavior.
► Integrated UpdateMoveSound() into movement functions (MoveTo() and LinearMoveDone()) so that sound updates dynamically as the entity moves.
This commit is contained in:
speedvoltage 2025-03-12 10:50:52 +01:00
parent a62efecf62
commit 77c3831eaf
2 changed files with 25 additions and 3 deletions

View file

@ -84,9 +84,9 @@ void CFuncMoveLinear::Spawn( void )
m_flMoveDistance = DotProductAbs( m_vecMoveDir, vecOBB ) - m_flLip;
}
m_vecPosition1 = GetAbsOrigin() - (m_vecMoveDir * m_flMoveDistance * m_flStartPosition);
m_vecPosition2 = m_vecPosition1 + (m_vecMoveDir * m_flMoveDistance);
m_vecFinalDest = GetAbsOrigin();
m_vecPosition1 = GetLocalOrigin() - ( m_vecMoveDir * m_flMoveDistance * m_flStartPosition );
m_vecPosition2 = m_vecPosition1 + ( m_vecMoveDir * m_flMoveDistance );
m_vecFinalDest = GetLocalOrigin();
SetTouch( NULL );
@ -394,3 +394,23 @@ int CFuncMoveLinear::DrawDebugTextOverlays(void)
}
return text_offset;
}
//-----------------------------------------------------------------------------
// Purpose: Runs a fix atfer the base version clearly dosen't cut it.
//-----------------------------------------------------------------------------
void CFuncMoveLinear::SetParent( CBaseEntity *pParentEntity, int iAttachment )
{
BaseClass::SetParent( pParentEntity, iAttachment );
// Recompute all positions
m_vecPosition1 = GetLocalOrigin() - ( m_vecMoveDir * m_flMoveDistance * m_flStartPosition );
m_vecPosition2 = m_vecPosition1 + ( m_vecMoveDir * m_flMoveDistance );
m_vecFinalDest = GetLocalOrigin();
}

View file

@ -36,6 +36,8 @@ public:
int DrawDebugTextOverlays(void);
void SetParent( CBaseEntity *pParentEntity, int iAttachment );
// Input handlers
void InputOpen( inputdata_t &inputdata );
void InputClose( inputdata_t &inputdata );