Vehicles (programming): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Half-Life 2 SDK Vehicles: Removed Signature.)
No edit summary
Line 13: Line 13:
==Half-Life 2 SDK Vehicles==
==Half-Life 2 SDK Vehicles==


* Fixing Jitterbugs in the players view. ( Multiplayer Issues Resolved )
Some information on fixing source vehicle code for use in Multiplayer can be found here.
 
[[Multiplayer Vehicle Fixes]]
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.
 
 
Open '''cl_dll/c_prop_vehicle.cpp'''
 
Find C_PropVehicleDriveable::C_PropVehicleDriveable() constructor.
 
Replace
<pre>
m_ViewSmoothingData.bDampenEyePosition = true;
</pre>
 
with
 
<pre>
m_ViewSmoothingData.bDampenEyePosition = false;
</pre>
 
 
Find C_PropVehicleDriveable::GetVehicleViewPosition
 
 
Replace
<pre>
VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV );
</pre>
 
with
 
<pre>
if( m_hPlayer->IsLocalPlayer() )
{
VehicleViewSmoothing( m_hPlayer, pAbsOrigin, pAbsAngles, m_bEnterAnimOn, m_bExitAnimOn, &m_vecEyeExitEndpoint, &m_ViewSmoothingData, &m_flFOV );
}
</pre>
 
 
Find void VehicleViewSmoothing
 
 
Replace
<pre>
if ( !bExitAnimOn )
{
Vector localEyeOrigin;
QAngle localEyeAngles;
 
pData->pVehicle->GetAttachmentLocal( eyeAttachmentIndex, localEyeOrigin, localEyeAngles );
  engine->SetViewAngles( localEyeAngles );
}
</pre>
 
with
 
<pre>
if ( pPlayer->IsLocalPlayer() )
{
if ( !bExitAnimOn )
{
Vector localEyeOrigin;
QAngle localEyeAngles;
 
pData->pVehicle->GetAttachmentLocal( eyeAttachmentIndex, localEyeOrigin, localEyeAngles );
  engine->SetViewAngles( localEyeAngles );
}
}
</pre>
 
 
Open '''cl_dll/c_prop_vehicle.h'''
 
In class C_PropVehicleDriveable replace
 
<pre>
virtual bool IsPredicted() const { return false; }
</pre>
 
with
 
<pre>
virtual bool IsPredicted() const { return true; }
</pre>

Revision as of 11:04, 7 November 2007

Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

Template:Abstract coding This article is meant to give an indepth analysis of the programming needed to create a vehicle in Source.

Interfaces

Multi Passenger Code

Jurassic Rage coding team has released multipassenger vehicle code here.

Pilotable Code

TheQuartz has released the Strider, Helicopter, and APC Source Code on his blog or in english

Half-Life 2 SDK Vehicles

Some information on fixing source vehicle code for use in Multiplayer can be found here. Multiplayer Vehicle Fixes