Porting PM_FlyMove to the clientgame


(uvhannes) #1

Morning,

I want to port a function called PM_FlyMove from bg_game to cgame:


/*
===================
PM_FlyMove

Only with the flight powerup
===================
*/
static void PM_FlyMove( void ) {
	int		i;
	vec3_t	wishvel;
	float	wishspeed;
	vec3_t	wishdir;
	float	scale;

	// normal slowdown
	PM_Friction ();

	scale = PM_CmdScale( &pm->cmd );

	//
	// user intentions
	//
	if ( !scale ) {
		wishvel[0] = 0;
		wishvel[1] = 0;
		wishvel[2] = 0;
	} else {
		for (i=0 ; i<3 ; i++) {
			wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;
		}

		wishvel[2] += scale * pm->cmd.upmove;
	}

	VectorCopy (wishvel, wishdir);
	wishspeed = VectorNormalize(wishdir);

	PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate);

	PM_StepSlideMove( qfalse );
}

Aim: replace my really choppy freecam in demo PlayBack.

Now, has any1 an idea or maybe sample. Cause im really, really stuck right here.

Greetings Hannes


(Nail) #2

not sure if this will help but DarkAngel posted a way to do spline camera within Et, couldn’t find his post here but I found a copy on our site.


(uvhannes) #3

ahm no: i wanted the function to fly around on the server. Recaming was sucessfully implemented. But my freecam is way too choppy atm :frowning:

(If you join a server and didnt join a team yet, your able to fly around on the server, but that hasnt been implemented in demoplayback :frowning: )

Thx anyway


(Elite) #4

Player movement is dictated by server in multiplayer. You are going to need to add client-side prediction to get it smooth.

I had this same problem myself the other day also with new entities I was placing in… actually it was for a dynamic light I was coding. Not sure about doing prediction right now though, sorry, I’m getting itno stuff I haven’t ever touched upon before as well. Lol, this is about the time you want to ring some necks for the documentation that was used int he development… :slight_smile:


(uvhannes) #5

i dont need it THAT smooth.

why would i need a “client-side prediction” cause in the freecam i got now i dont use it either. And since pmove is client and serverside wouldnt it be possible to just port it somehow?

If you managed to get that done before maybe u still got some snippets i could have a look at.

thx for your reply anyways :slight_smile:


(Elite) #6

Actually, I am just still in progress… sorry. When I get something done I’ll give this thread another look though. Probably by then you will have allready got it anyhow…

========

Also, in demo playback, I believe the prediction does not work, and that is why it is choppy.

If it’s choppy ALL the time, then try changing the velocity to use a float instead and see if you get more of what you want.

========

EDIT:

I totally slipped this from my mind.
if you allready know exactly what you need, as it sounds so, just put in something like:

#ifdef CGAMEDLL
   code...
#else
   code...
#endif

With this approach you can have separate code for the cgame module, and perform any extra steps needed to make it work. Not sure what it takes to finish it to what you want, but atleast that will separate it…

Make sure you check that it is in demo playback as well:

#ifdef CGAMEDLL
   if(cg.demoPlayback) {
      code...
   }
   code...
#else
   code...
#endif

Probably going to need an extern somewhere in there to get that working though… so just add it wherever you want and the bg_ file can access it still. Don’t have the source open right now to take a peek at, but ya, just figure out how you are going to access it if you are going that route. Otherwise you are going to need like a boolean passed in when you call it from cgame. In that case you can just do something like:

#ifdef CGAMEDLL
static void PM_FlyMove( qboolean demoPlayback ) { 
   if(demoPlayback) {
      code for results you want....
      return if necessary...
   }
   code...
}
#else
static void PM_FlyMove( void ) {
   code...
}
#endif

Although, I’m not sure how much this is going to help. Obviously the code exists in both modules allready… so it’s not, in theory, going to make any difference…period.

It would be more helpful to see where you are actually calling it and what not.


(uvhannes) #7

well pretty simple:

by now the freecam comes with the consolecommands.c since it was the easiest way to implement it.

ill go through your ideas, just returned.

thx so far


(Elite) #8

I’m not much help… but I try :slight_smile: