View Full Version : 3rd Person View & Player Model Issue

05-24-2007, 07:41 AM
Hi there,
first of all, i have made a sp mod and added the 3rd person view from the source sdk wiki. Now I have a strange problem with my player model.
The following screenshots show my problem:
- screen01 (http://loz.goddzilla.de/user/error01.jpg) -
- screen01 (http://loz.goddzilla.de/user/error02.jpg) -
- screen01 (http://loz.goddzilla.de/user/error03.jpg) -

It seems that the angle of the model is independent of the angle of the mouse or the viewport or whatsoever...
came somebody across such a problem or has anyone a solution ?

greetz goddzillajk

05-24-2007, 12:59 PM
you didnt need to really 'add' third person.. atleast not in multiplayer im not sure in singleplayer.. just have the client execute 'thirdperson' command on spawn, ext.. you would also want to remove the lines making it disable it if sv_cheats = 0, because the default thirdperson code by valve keeps the camera vectors aligned with the player

i hope this helps

D. evil
05-24-2007, 11:54 PM
I'm pulling apart a 3rd person view at the moment and it is working almost perfectly except for the fact that the model doesn't load when I run the map, but it does load if I turn on the flash light or fire my gun (weirdness? I agree). Anyways, apart from that it is working.

Anyone else had that problem and the solution (more importantly) If so do let me know. I'll be working pretty hard-core on the engine for the next while and most likely will start writing useful tutorials (unlike the existing ones online) that anyone can understand so any help along the way would be highly appreciated (hell, I'll even put you in the credits for any mods I get involved in)

05-25-2007, 05:38 AM
You can use VALVe's 3rd person view, you just need to comment out the code if there is more than 1 player... and take out the FCVAR_CHEAT line.

05-26-2007, 08:54 PM
Okay, I'm a coding newb here trying to get some useful info from experienced people.

When I use 'thirdperson' in my mod's console, I stare at my character's right temple and when I try to fire my gun it triggers several failed assertions in my debugger.

Can I get a detailed explanation of what to change in the code to get the third person view to work correctly (view from behind the model) and why it works that way (so I can learn some how-to stuff)?

Also, how do I get it to display the animations in third person? My character just stands in the standard "arms out" pose and jumps to the fire position for one frame when I fire before reverting back to the "arms out" again.

D. evil
05-27-2007, 03:06 AM
well, no solution to my problem but I think I've almost figured it out, I know what code I need, just have to find out where to put it :)

Anyways, WHITESTUFF! wad up! I can answer your questions:

First of all for looking at the side of your players head, there is a slight typo in the code, if you go to the in_camera.cpp and find this:

static ConVar cam_idealyaw, the numeric value should be 0 instead of 90

this basically sets up the yaw angle and 0 is the position behind the player.

Next, for your model to animate you need to actually tell it when to animate and the code can be found here: http://developer.valvesoftware.com/wiki/Third_Person_Camera

I wouldn't follow any of the earlier code as I've found it to be pretty upside down, but the animation part is ok and works.

You'll need to change your model from the standard "player" model if you want to see a lot of animation going on, but the player model will give a running and sort of shooting animation.

05-27-2007, 04:52 AM
first, thanks 2 all.
hmm, i think my problem has nothing to do with the thirdperson stuff.
This strange bug appeared when I added shadows to my custom player.

If I add these lines to my client player file the bug shows up.

ShadowType_t C_BaseLOZPlayer::ShadowCastType( void )
if ( !IsVisible() )


And I do not understand why, because in the original hl2mp sdk the hl2mp player( c_hl2mp_player.cpp ) has the same code snippet.

Okay I have haxxed(lol) now the problem.
It was the pitch of the players LocalAngels that caused this bug.
I set the pitch just to zero in my players clientthink(on the client side) function.
This solution does not satisfy me but it works for now.

thanks to all for your help.

05-27-2007, 11:37 PM
First of all for looking at the side of your players head, there is a slight typo in the code, if you go to the in_camera.cpp and find this:

static ConVar cam_idealyaw, the numeric value should be 0 instead of 90

I tinkered with this and found that entering 0 did nothing. I tried 1 as well, and the same result. It turns out that for some reason 180 will give me the proper camera angle, though 0 is explained in the SDK documentation as well as suggested here. Why's that?

Check your PM's D. evil.

D. evil
05-28-2007, 11:45 PM
Great to see a few posts going on, was worried the forum was dead :) Actually my 3rd person camera is for single player so I'm probably doing it a little different from goddzillajk, anyhoo I should have time to start looking at it again today or tomorrow so hopefully I can post something about a workin single player 3rd person soon enough

D. evil
05-29-2007, 02:50 AM
Sweet, I cracked it. My problem was what I figured it to be, so I'll do it all again from scratch and write up a tutorial and link to that tutorial on how to get a fully working animated 3rd person camera working. Watch this space...

05-29-2007, 05:03 AM
Very great, then Ill wait for your tutorial :).
My strange bug appeared again since I try to add an attachment to my player model.

05-30-2007, 12:01 AM
I knew the code. CS:S has the third person thing, and it's good. But the only thing is you have to be dead for it to work right. But even then you can see through the walls and stuff.

07-14-2007, 08:56 AM
I think maybe we guys should just disable calculating player view?
Like somewhere in CBasePlayer::CalcView just disable other calls?
Maybe disable only angles calculation?
Cause 3rd camera calculating it own angles, and when player calculation angles too it cause a bug?
I notice that when use a crowbar and start kicking wall, like ViewPunch align to player model...

07-14-2007, 10:22 PM
I think we guys should make some bug list of 3rd camera bugs for SP to know with what we have deal and on what we will be working.
So I notice next few bugs:
1) After map restart +camchange not working any more
2) Player Transparency work pretty poor.
3) Something wier may happend with weapons like you stay and do dying anything, and weapon play muzzleflashes and ejecting brass shelves with something delays in time
4) Camera not working with vehicles pretty well.
5) Seems like model not disappearing when radgoll model spawns on place.
6) After changing to 3rd and 1st again, the sound of steps still coming from player model, it cause that many steps sound mixes...
7) player abs and local angles must work separately from EyeAngles
8) Crounching and jumping not synchronyzed with animations well
9) We see 2 muzzelfashes from fist and third person
10) We can't detect that thirdperson mode turned on in the server

So thats what I have for now, did you guys notice something else?

07-14-2007, 11:20 PM
So I figure out pitch bug.
That's solve that strange player model diving in ground bug.

Just :

void CHL2_Player::PostThink( void )
// other game code
// Lolmen's fix for 3rd person : this will fix third person pitch bug
QAngle angles = GetLocalAngles();
angles[PITCH] = 0;
SetLocalAngles( angles );

And in class C_BaseHLPlayer
you should declare an virtual method like virtual void AddEntity( void );
and implement it as this :

// Purpose: for 3rd person
void C_BaseHLPlayer::AddEntity( void )
// Lolmen : Zero out model pitch, blending takes care of all of it.
SetLocalAnglesDim( X_INDEX, 0 );

So enjoy!