coding: fixing first person spectating

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

coding: fixing first person spectating

Post by torhu »

I've tried to add first person spectating to a mod which originally had only a third person chasecam mode, plus free spectating. At first it seemed to work, HUD and first person animations were correct. Mostly I only had to set ent->client->sess.spectatorState = SPECTATOR_FOLLOW; in a function called ChaseCam_Start() in g_cmds.c. The 'follow' console command would also give a partially working 1st person mode. Then I traced down and fixed 5-6 problems, and all seemed fine. I could switch between clients, and 1st and chasecam modes. But this was all with bots.

When I tried spectating a human player, the view position would still follow him. But the view direction didn't, you had to turn with the mouse. And the hud and weapon animations seemed to be a mix of the player and the spectator's. You could actually fire the gun and the animations would play when you were spectating. And the view flickered between two different views, mostly showing the view that the spectator controlled. The other view could be the spectated player's I guess, but it was shown too briefly for me to see that. The player spectated didn't see anything out of the ordinary.

And the guy that help me test, said that he got some sort of flickering when spectating bots. But it was perfect when I tried. We even tried kicking the bot and reconnecting in varying orders to see if the clientnumbers mattered or anything like that.

I've made diffs to see changes between the mod and q3 1.32. The mod seems to be based on 1.27g, so maybe I should use that instead. I couldnt' find any interesting changes in cg_draw.c or cg_view.c. I've diffed g_active.c, g_client.c, and g_cmds.c, but the diffs are maybe 5000 lines altogether, so I'm not looking forward to reading them.

I guess I need to find something that would make spectating bots and humans be different. It seems you are somewhere inbetween spectator and player when spectating humans. Any hints?
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
Lenard
Posts: 737
Joined: Mon Aug 04, 2003 7:00 am

Post by Lenard »

Looks like a cool game. :icon25: :icon27:
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

AnthonyJ already said it on PQ, it's probably prediction causing trouble, so suppress it on the client-side when a player is spectating.
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

When I tried spectating a human player, the view position would still follow him. But the view direction didn't, you had to turn with the mouse. And the hud and weapon animations seemed to be a mix of the player and the spectator's. You could actually fire the gun and the animations would play when you were spectating.
Would prediction problems cause this? Where would I start looking for it then? So this could be the server overriding the client's playerstate? Shouldn't spectating bots give the same problems then? Or maybe they don't have a playerstate that's calculated in pmove. I'm in a hurry to fix this before my vacation, so sorry if I'm asking stupid questions here. ;)
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

Found something interesting in CG_PredictPlayerState():

// demo playback just copies the moves
if ( cg.demoPlayback /*|| (cg.snap->ps.pm_flags & PMF_FOLLOW*/) ) {
CG_InterpolatePlayerState( qfalse );
return;
}

That wasn't commented out in vanilla q3...

Now it's time to test. :icon31:
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

That was it, works like a charm now. You're all invited to try out Western Quake III, so I can get some more n00bs to frag. :p
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
Post Reply