Posted by: Crono
Date posted: Dec 08 2004 User Rating: 1 out of 5.0 | Number of views: 9868 Number of comments: 9 | Description: Collision check, translucency |
I believe this to be an accurate-ish remix of Omega's improved third person camera for Half-Life 1, located here.
I will hope this is correct but assume it is not, and any suggestions or corrections are more than welcome. Being that this is a snippet, I will endeavor to keep it terse.
Line numbers are reliant on following modifications in order. All of this takes place in cl_dll\in_camera.cpp.
@Line 20
| | | | #define CAM_MIN_DIST 30.0 |
Remove this line.
@Line 27
| | | #define CAM_MIN_DIST 16.0 #define CAM_MAX_DIST 96.0 #define CAM_HULL_OFFSET 6.0
static Vector CAM_HULL_MIN(-CAM_HULL_OFFSET,-CAM_HULL_OFFSET,-CAM_HULL_OFFSET); static Vector CAM_HULL_MAX( CAM_HULL_OFFSET, CAM_HULL_OFFSET, CAM_HULL_OFFSET);
|
Insert.
@Lines 395 - 412
| | | else { if( camAngles[ YAW ] - viewangles[ YAW ] != cam_idealyaw.GetFloat() ) camAngles[ YAW ] = MoveToward( camAngles[ YAW ], cam_idealyaw.GetFloat() + viewangles[ YAW ], CAM_ANGLE_SPEED ); if( camAngles[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch.GetFloat() ) camAngles[ PITCH ] = MoveToward( camAngles[ PITCH ], cam_idealpitch.GetFloat() + viewangles[ PITCH ], CAM_ANGLE_SPEED ); if( !C_BasePlayer::GetLocalPlayer() ) { camAngles[ 2 ] = dist; } else { trace_t tr; float adjDist = dist; C_BasePlayer* localPlayer = C_BasePlayer::GetLocalPlayer();
Vector origin = localPlayer->GetLocalOrigin(); origin += localPlayer->GetViewOffset();
AngleVectors( QAngle(camAngles.x, camAngles.y, camAngles.z), &camForward, NULL, NULL );
UTIL_TraceHull( origin, origin - (camForward * dist), CAM_HULL_MIN, CAM_HULL_MAX, MASK_SOLID, NULL, &tr );
if( tr.fraction < 1.0 ) { adjDist = dist * tr.fraction; localPlayer->SetRenderMode( kRenderTransColor ); localPlayer->SetRenderColorA( (byte)(255 * tr.fraction) ); } else { adjDist = dist; }
if( adjDist < CAM_MIN_DIST ) adjDist = CAM_MIN_DIST;
if( adjDist > CAM_MAX_DIST ) adjDist = CAM_MAX_DIST;
camAngles[ 2 ] = MoveToward( camAngles[ 2 ], adjDist, CAM_ANGLE_SPEED ); } }
m_vecCameraOffset[ 0 ] = camAngles[ 0 ]; m_vecCameraOffset[ 1 ] = camAngles[ 1 ]; m_vecCameraOffset[ 2 ] = camAngles[ 2 ]; }
|
Replace. |
|
User Comments
Showing comments 1-9
|
Is this SP or MP? I'm having troubles getting the guy to show at all in SP code, its either the floating hand model or nothing (I still havn't found the playerdraw stuff). |
|
Sorry, this was done entirely with the barebones MP SDK setup, I was sure I'd mentioned that somewhere.
If I open single player Half-Life 2 right now, then set sv_cheats 1, then type "thirdperson" in console, I have no player model. If I turn the flashlight on and back off, I go from no player model to a flat colored ugly player model with no animation.
I don't think it's your fault or my code's.Edited by Crono on Dec 09 2004, 15:36:45
|
|
This has been covered in the forums. I believe the problem is that Valve didn't intend thirdperson to be used in SP, and as such they never bothered doing the player model. Apparently looking at the model shows that it's only got 3 anims. If you make your own player model it should work fine :) I'll tell you when I've got it working...
[edit]
I can confirm that this tutorial does what it's supposed to just fine :) You still need your own player model though.Edited by jim_the_coder on Dec 19 2004, 09:28:50
|
|
Has anybody had any luck getting this to work while in the vehicles? I got it working while running around (even placed it over the players head). But, when I get in the Jeep the camera goes back to looking to the left of where the player/vehicle is actually looking.
Any ideas what I ccan do about this? |
|
(at about line 471)
| | | // Do allow third person in TF2 for now #if !defined( TF2_CLIENT_DLL ) && !defined( CSTRIKE_DLL )
#if !defined( _DEBUG ) if ( gpGlobals->maxClients > 1 ) { // no thirdperson in multiplayer. return; } #endif
#endif
|
This is preventing thirdperson in multiplayerEdited by paccer on Feb 10 2005, 11:07:09
|
|
Yes it does. If you comment out the return, it'll work though. I'm experiencing a different problem now though; I see my character from the side. So if I press the "walk forward" key, the model will walk to the right of my screen, which is his front. Does anyone know how to fix this? |
|
find idealyaw (in_camera.cpp), its defined somewhere in the top as far as i remember - set it to 0 instead of 90, and delete your config.cfg or make sure c_ commands are same as defined in in_camera.cpp.. Alternatively, you can just set c_idealyaw to 0, but it will default to 90 then.
edit: My translucency still doesnt work tho - does it work for anyone else?
edit: Sorry.. my translucency actually works fine :)Edited by paccer on Feb 10 2005, 11:06:19
|
|
|
This is a fantastic tutorial and was just what I needed - thank you. And thank you to paccer, whos comments helped me fix the yaw value.Edited by Vash on Feb 19 2005, 10:21:55
|
|
|
how do you switch the model ? is there an easy way to do it while using a model like alyx that is already in the game? Thanks for the help. |
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (14 guests)
|
|