Hey guys,
This is probably the first of many questions for this mod, but here goes...
I'm making a mod using Darkplaces that is essentially a biking game. I'm using a bit of hardware to interface with a real bicycle mounted on a stationary trainer, which then feeds into the mod. Biking faster on the real bike means you race faster in the game, turning the handlebars turns the view etc.
I'm trying to get the feel of biking just right and I have two questions.
1. Is there a way to manipulate SV_Friction for a forward movement only?
I've been playing with the idea of using a trigger to manipulate SV_Friction on rough terrain (to slow you down) and icy terrian (slip n' slide), so I'd like to keep that if I can. But if I can get it to affect forward movement only, then I might be able to make some better headway going uphill and downhill. I was thinking something like
if ((self.velocity_z) > 1) {
stuffcmd(self,"sv_friction... lots of friction, you're going uphill so it should be harder and require you to pedal more to go the same distance");
}
if ((self.velocity_z) < 1) {
stuffcmd...etc. You should speed up quite a bit going downhill.
But I need it to affect forward movement only. So if you're turned sideways on a hill or ramp, you actually won't go anywhere. If you face up or downhill, you then start to slide. The way I worked it out above doesn't really address this issue of "facing". I almost need like a trigger_push that pushes you backwards while going uphill and forwards while going downhill.
2. How can I make the player turn without using +left and +right?
The handlebars do the turning, and it is a type of "constant turn". When your handlebars are titled to the left, you continuously turn left. The sharper they are turned, the more heavily you turn in the game. A regular mouse movement would just turn you a certain amount and then stop. I've done this so far by using the prydoncursor and a type of call of duty aiming style. When the cursor position is very close to the center, you don't turn. Move it a little to the left, you continuously turn left slowly. Move it more to the left, you turn a lot. I vary the actual turn speed by stuffing cl_yawspeed proportional to the cursor position.
void () CheckTurn =
{
local string t;
if (!((self.flags) & FL_ONGROUND)) {
return;
}
if ((self.cursor_active) < 1) {
stuffcmd (self, "cl_yawspeed 140\n");
return;
}
t = ftos (200*((self.cursor_screen_x)*(self.cursor_screen_x))); <-- I needed to square the value to make it positive.
stuffcmd (self, "cl_yawspeed ");
stuffcmd (self,t);
stuffcmd (self, "\n");
if ((self.cursor_screen_x) > 0.05) {
stuffcmd (self, "+right\n");
}
else {
if ((self.cursor_screen_x) < -0.05) {
stuffcmd (self, "+left\n");
}
else {
stuffcmd (self, "-left\n");
stuffcmd (self, "-right\n");
This seems to work pretty well, but it's a little buggy and I know it's a backwards way of doing things and I'm sure there's something out there better. Between v_right, v_up, and v_forward I can't seem to figure this out. I need like a v_yaw or something. Any suggestions?
Thanks,
Alex
ps. I'd like to do this all in QC if possible. I'm not really familiar with CSQC or what it really even is.