Talk:Point viewcontrol: Difference between revisions
No edit summary |
(Bug fix for following path_corners) |
||
Line 42: | Line 42: | ||
--[[User:Ndnichols|Ndnichols]] 20:42, 9 Aug 2006 (PDT) | --[[User:Ndnichols|Ndnichols]] 20:42, 9 Aug 2006 (PDT) | ||
There is an apparent bug with getting the camera to follow the path_controls set up for it. To fix this, go to triggers.cpp and do the following. To the declaration of CTriggerCamera, add the following private member: | |||
Vector m_vecLastPos; | |||
and also declare it with the DEFINE_FIELD macro (I believe this is necessary for the camera to save and load properly.) | |||
DEFINE_FIELD( m_vecLastPos, FIELD_VECTOR), | |||
In CTriggerCamera::Enable() is the code block | |||
if ( m_pPath ) | |||
{ | |||
if ( m_pPath->m_flSpeed != 0 ) | |||
m_targetSpeed = m_pPath->m_flSpeed; | |||
m_flStopTime += m_pPath->GetDelay(); | |||
} | |||
Change this block to be | |||
if ( m_pPath ) | |||
{ | |||
if ( m_pPath->m_flSpeed != 0 ) | |||
m_targetSpeed = m_pPath->m_flSpeed; | |||
m_flStopTime += m_pPath->GetDelay(); | |||
m_vecMoveDir = m_pPath->GetLocalOrigin() - GetLocalOrigin(); | |||
m_moveDistance = VectorNormalize( m_vecMoveDir ); | |||
m_flStopTime = gpGlobals->curtime + m_pPath->GetDelay(); | |||
} | |||
else | |||
{ | |||
m_moveDistance = 0; | |||
} | |||
Near the end of the Enable() function is the line | |||
m_moveDistance = 0; | |||
Change this to be | |||
m_vecLastPos = GetAbsOrigin(); | |||
Now, in the CTrigger::Move() function, change the line that reads | |||
m_moveDistance -= m_flSpeed * gpGlobals->frametime; | |||
to read | |||
m_moveDistance -= VectorNormalize(GetAbsOrigin() - m_vecLastPos); | |||
Finally, add the line | |||
m_vecLastPos = GetAbsOrigin(); | |||
to the very end of the Move() function. | |||
(I believe the two bugs were that m_moveDistance wasn't being calculated properly in Enable(), and that the m_flSpeed * gpGlobals->frametime expression reported moving much farther than actually happened. This caused the camera to think it had arrived at the destination camera before it actually had.) | |||
I haven't tested this extensively at all, but it seems to work for me. Please let me know if you have any issues. | |||
--[[User:Ndnichols|Ndnichols]] 13:09, 10 Aug 2006 (PDT) |
Revision as of 13:09, 10 August 2006
There is a bug with the camera pointing at the targetted entity. Currently (8/9/06) the camera always points to the origin when a target is set. To fix this, go into the code and open triggers.cpp. Starting at line 2892, the code looks like
if ( m_iAttachmentIndex ) { Vector vecOrigin; m_hTarget->GetBaseAnimating()->GetAttachment( m_iAttachmentIndex, vecOrigin ); VectorAngles( vecOrigin - GetLocalOrigin(), vecGoal ); } else { if ( m_hTarget ) { VectorAngles( m_hTarget->GetLocalOrigin() - GetLocalOrigin(), vecGoal ); } else { // Use the viewcontroller's angles vecGoal = GetAbsAngles(); } }
Change the code to be this:
if ( m_iAttachmentIndex ) { Vector vecOrigin; m_hTarget->GetBaseAnimating()->GetAttachment( m_iAttachmentIndex, vecOrigin ); VectorAngles( vecOrigin - GetAbsOrigin(), vecGoal ); //Changed to use AbsOrigin } else { if ( m_hTarget ) { VectorAngles( m_hTarget->GetAbsOrigin() - GetAbsOrigin(), vecGoal ); //Changed to use AbsOrigin } else { // Use the viewcontroller's angles vecGoal = GetAbsAngles(); } }
--Ndnichols 20:42, 9 Aug 2006 (PDT)
There is an apparent bug with getting the camera to follow the path_controls set up for it. To fix this, go to triggers.cpp and do the following. To the declaration of CTriggerCamera, add the following private member:
Vector m_vecLastPos;
and also declare it with the DEFINE_FIELD macro (I believe this is necessary for the camera to save and load properly.)
DEFINE_FIELD( m_vecLastPos, FIELD_VECTOR),
In CTriggerCamera::Enable() is the code block
if ( m_pPath ) { if ( m_pPath->m_flSpeed != 0 ) m_targetSpeed = m_pPath->m_flSpeed; m_flStopTime += m_pPath->GetDelay(); }
Change this block to be
if ( m_pPath ) { if ( m_pPath->m_flSpeed != 0 ) m_targetSpeed = m_pPath->m_flSpeed; m_flStopTime += m_pPath->GetDelay(); m_vecMoveDir = m_pPath->GetLocalOrigin() - GetLocalOrigin(); m_moveDistance = VectorNormalize( m_vecMoveDir ); m_flStopTime = gpGlobals->curtime + m_pPath->GetDelay(); } else { m_moveDistance = 0; }
Near the end of the Enable() function is the line
m_moveDistance = 0;
Change this to be
m_vecLastPos = GetAbsOrigin();
Now, in the CTrigger::Move() function, change the line that reads
m_moveDistance -= m_flSpeed * gpGlobals->frametime;
to read
m_moveDistance -= VectorNormalize(GetAbsOrigin() - m_vecLastPos);
Finally, add the line
m_vecLastPos = GetAbsOrigin();
to the very end of the Move() function.
(I believe the two bugs were that m_moveDistance wasn't being calculated properly in Enable(), and that the m_flSpeed * gpGlobals->frametime expression reported moving much farther than actually happened. This caused the camera to think it had arrived at the destination camera before it actually had.)
I haven't tested this extensively at all, but it seems to work for me. Please let me know if you have any issues. --Ndnichols 13:09, 10 Aug 2006 (PDT)