Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Third Person Camera View

A Tutorial for Half-Life 2

No ads for members. Membership is 100% free. Sign up!
There are a few articles on Wavelegth that deal with making a better Third Person camera view. These are good links to check and perhaps implement in your mod, however, neither of them deals with the problem encountered while using the camera in a vehicle. (Those who have tried know what I'm talking about.) This page shows how to get the camera working properly with the vehicles. I am not very articulate, so, I'll let the code do the talking. All the fixes here will assume that you have already implemented the code found in that first link. The second link is optional and just has a few fixes for the first one. * First, you will probably want to set the Max camera distance higher, so you can see the entire car * Next, this part comes from the first article above: if( !C_BasePlayer::GetLocalPlayer() ) {// this code can be hit from the main menu, where it will crash camAngles[ 2 ] = dist; // if there's no localplayer to calc from } else { trace_t tr; C_BasePlayer* localPlayer = C_BasePlayer::GetLocalPlayer(); Vector origin = localPlayer->GetLocalOrigin(); // find our player's origin origin += localPlayer->GetViewOffset(); // and from there, his eye position AngleVectors( QAngle(camAngles.x, camAngles.y, camAngles.z), &camForward, NULL, NULL ); // get the forward vector Replace that with this: C_BasePlayer* localPlayer = C_BasePlayer::GetLocalPlayer(); Vector origin; if( localPlayer->IsInAVehicle () ) { IClientVehicle *pVehicle = localPlayer->GetVehicle(); int nRole = pVehicle->GetPassengerRole( localPlayer ); pVehicle->GetVehicleViewPosition(nRole,&origin,&viewangles); AngleVectors( viewangles, &camForward, NULL, &camUp ); // get the forward/up vectors camAngles[ 0 ] = viewangles.x + cam_carpitch.GetFloat(); camAngles[ 1 ] = viewangles.y; camAngles[ 2 ] = f_carDist; //DevMsg(1, "IsInAVehicle CamAngles X:%d |Y:%d| Z:%d\n", camAngles[ 0 ] , camAngles[ 1 ], camAngles[ 2 ] ); } else { origin = localPlayer->GetLocalOrigin(); // find our player's origin origin += localPlayer->GetViewOffset(); // and from there, his eye position AngleVectors( QAngle(camAngles.x, camAngles.y, camAngles.z), &camForward, NULL, &camUp ); // get the forward/up vectors }

Tutorial by WikiPedia.

Sign up to access this!
  • HALF-EFIL avatar
    HALF-EFIL Joined 12y ago
    Offline
    3,092 points Ranked 3381st
    10 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • Reached 1,000 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    • 1 year a member Medal icon
    access_time 10y
    Please say to me where do i put these into hl2? I am new at scripting. :)
    Hard mode ON! avatar
    Mantra
    Hard mode ON!
    URL to post:
  • killer89 avatar
    killer89 Joined 14y ago
    Offline
    3,735 points Ranked 2125th
    10 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • Reached 1,000 Points Medal icon
    • Reached 2,500 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    access_time 11y
    Posted by roryos01 Shouldn't this just be in the normal script section?
    Well, this is a HL2-related script. You didn't read it all, didn't you?
     avatar
    URL to post:
  • roryos01 avatar
    roryos01 Joined 12y ago
    Offline
    116 points Ranked 65415th
    access_time 12y
    Shouldn't this just be in the normal script section?
    I r tah suxorz!!!
    URL to post:
  • killer89 avatar
    killer89 Joined 14y ago
    Offline
    3,735 points Ranked 2125th
    10 medals 1 legendary 1 rare
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • Reached 1,000 Points Medal icon
    • Reached 2,500 Points Medal icon
    • One month a member Medal icon
    • 6 months a member Medal icon
    access_time 12y
    Being able to switch from first person to WORKING third person and vice versa.... F U C K I N WEET!
     avatar
    URL to post:
  • Mr Ricktus avatar
    Mr Ricktus Joined 14y ago
    Offline
    103 points Ranked 68672nd
    access_time 13y
    Doesnt using the comands thirdperson then doing something along the lines on cam_idleyaw 0 or 360, work? It works in CS:S
    Satan is my neighbor avatar
    Mantra
    Satan is my neighbor
    URL to post:
  • Cliffe^^ avatar
    Cliffe^^ Joined 13y ago
    Offline
    399 points Ranked 47711th
    access_time 13y
    Nice tut(Y)
    ...KARMA... avatar
    Mantra
    ...KARMA...
    URL to post:
  • TSX avatar
    TSX Joined 14y ago
    Offline
    3,451 points Ranked 2354th
    access_time 14y
    FUCKING SWEET!! i love this tut someone should give you a dollar
    Sorry but our princess is in a avatar
    Mantra
    Sorry but our princess is in a
    URL to post:

Embed

menu
Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Authors
n/a
n/a

Submitter

Guest avatar
Guest Joined 14y ago
Offline
19 medals 4 legendary 6 rare
  • Submitted 100 Skins Medal icon
  • Submitted 50 Maps Medal icon
  • Submitted 200 Threads Medal icon
  • Submitted 30 Tutorials Medal icon
  • Submitted 50 Skins Medal icon
  • Submitted 20 Maps Medal icon
Guest
Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Intermediate

Attributes

Miscellaneous
Genre
Other/Misc

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • 1
  • 12.8k
  • 8
  • 14y
  • 8y

More from Submitter

menu

WiPs by Submitter

menu

More Scripting Tutorials