Multiplayer Vehicle Fixes: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
==Brief discussion== | |||
These fixes are to correct some issues with using Valves vehicles code in a multiplayer game. | These fixes are to correct some issues with using Valves vehicles code in a multiplayer game. | ||
A true way of doing vehicles in Source Multiplayer would be to write prediction code for the client, but this is not possible with the current engine. The only other option would be to write your own vehicle movement code, which is no easy task for complicated vehicles like the buggy. | A true way of doing vehicles in Source Multiplayer would be to write prediction code for the client, but this is not possible with the current engine. The only other option would be to write your own vehicle movement code, which is no easy task for complicated vehicles like the buggy. | ||
==Laggy Vehicle View== | |||
A couple of changes will fix the laggy view, but present different issues. One being the cameras position no longer interpolating to where it should. | |||
Open '''cl_dll/c_prop_vehicle.cpp''' | Open '''cl_dll/c_prop_vehicle.cpp''' | ||
Line 22: | Line 24: | ||
Open '''cl_dll/c_prop_vehicle.h''' | |||
In class C_PropVehicleDriveable replace | |||
<pre> | <pre> | ||
virtual bool IsPredicted() const { return false; } | |||
</pre> | </pre> | ||
Line 33: | Line 35: | ||
<pre> | <pre> | ||
virtual bool IsPredicted() const { return true; } | |||
</pre> | </pre> | ||
==Vehicle Camera affecting other players== | |||
A simple fix is to make sure the vehicles view changes only affect the local player. | |||
Open '''cl_dll/c_prop_vehicle.cpp''' | |||
Find void VehicleViewSmoothing | Find void VehicleViewSmoothing | ||
Line 72: | Line 76: | ||
Find C_PropVehicleDriveable::GetVehicleViewPosition | |||
Replace | |||
<pre> | <pre> | ||
VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV ); | |||
</pre> | </pre> | ||
Line 83: | Line 87: | ||
<pre> | <pre> | ||
if( m_hPlayer->IsLocalPlayer() ) | |||
{ | |||
VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV ); | |||
} | |||
</pre> | </pre> |
Revision as of 10:58, 7 November 2007
Brief discussion
These fixes are to correct some issues with using Valves vehicles code in a multiplayer game. A true way of doing vehicles in Source Multiplayer would be to write prediction code for the client, but this is not possible with the current engine. The only other option would be to write your own vehicle movement code, which is no easy task for complicated vehicles like the buggy.
Laggy Vehicle View
A couple of changes will fix the laggy view, but present different issues. One being the cameras position no longer interpolating to where it should.
Open cl_dll/c_prop_vehicle.cpp
Find C_PropVehicleDriveable::C_PropVehicleDriveable() constructor.
Replace
m_ViewSmoothingData.bDampenEyePosition = true;
with
m_ViewSmoothingData.bDampenEyePosition = false;
Open cl_dll/c_prop_vehicle.h
In class C_PropVehicleDriveable replace
virtual bool IsPredicted() const { return false; }
with
virtual bool IsPredicted() const { return true; }
Vehicle Camera affecting other players
A simple fix is to make sure the vehicles view changes only affect the local player.
Open cl_dll/c_prop_vehicle.cpp
Find void VehicleViewSmoothing
Replace
if ( !bExitAnimOn ) { Vector localEyeOrigin; QAngle localEyeAngles; pData->pVehicle->GetAttachmentLocal( eyeAttachmentIndex, localEyeOrigin, localEyeAngles ); engine->SetViewAngles( localEyeAngles ); }
with
if ( pPlayer->IsLocalPlayer() ) { if ( !bExitAnimOn ) { Vector localEyeOrigin; QAngle localEyeAngles; pData->pVehicle->GetAttachmentLocal( eyeAttachmentIndex, localEyeOrigin, localEyeAngles ); engine->SetViewAngles( localEyeAngles ); } }
Find C_PropVehicleDriveable::GetVehicleViewPosition
Replace
VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV );
with
if( m_hPlayer->IsLocalPlayer() ) { VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV ); }