Page 1 of 1
Just need a quick pointer
Posted: Thu Dec 13, 2007 6:30 pm
by phreakachew
Hey all,
I need to change the player movement axis to the world axis instead of the player view (ie: pressing forward would always move north.)
I have scoured bg_pmove.c, but haven't found it yet.
Any help?
Re: Just need a quick pointer
Posted: Thu Dec 13, 2007 8:11 pm
by ^misantropia^
This would've belonged better in 'Programming Discussion' but not to worry. Off the top of my head, does inserting this snippet at the top of PM_Accelerate() solve your needs? I'm a bit stretched for time right now and I confess to not actually testing it, so let me know if you run into trouble or would like an overview of its inner workings (I skipped on comments, this time).
Code: Select all
int total;
wishdir[0] = 0;
wishdir[1] = 0;
wishdir[2] = 0;
#define F(x) (x < 0 ? -1 : x > 0)
wishdir[0] = F(pm->cmd.rightmove);
wishdir[1] = F(pm->cmd.forwardmove);
wishdir[2] = F(pm->cmd.upmove);
#define G(x) (x != 0)
total = G(wishdir[0])
+ G(wishdir[1])
+ G(wishdir[2]);
if (total > 1) {
wishdir[0] /= total;
wishdir[1] /= total;
wishdir[2] /= total;
}
Re: Just need a quick pointer
Posted: Fri Dec 14, 2007 2:29 pm
by phreakachew
There is a programming section?!?!
Well, in PmoveSingle() in bg_pmove.c I found this code that loads the player view axis:
AngleVectors(pm->ps->viewangles, pml.forward, pml.right, pml.up);
So I set the pml.foward, .right, and .up to absolute values:
pml.forward[0] = 90;
pml.forward[1] = 0;
pml.forward[2] = 0;
pml.right[0] = 0;
pml.right[1] = -90;
pml.right[2] = 0;
pml.up[0] = 0;
pml.up[1] = 0;
pml.up[2] = 90;
And that seems to work fine.