Vehicles (programming)
Template:Abstract coding This article is meant to give an indepth analysis of the programming needed to create a vehicle in Source.
Interfaces
- IVehicle - Vehicle Generalizations
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
- Fixing Jitterbugs in the players view. ( Multiplayer Issues Resolved ) --Skidz 19:24, 11 Oct 2007 (PDT)
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
m_ViewSmoothingData.bDampenEyePosition = true;
with
m_ViewSmoothingData.bDampenEyePosition = false;
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 ); }
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 ); } }
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; }
Credits for this tutorial go to:
RomeoJGuy