Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Help with self.velocity

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Wed Sep 12, 2007 11:00 pm Post subject: Help with self.velocity |

Guys, I'm trying to get the player to slow down as he picks up nails and rockets. I added this code to PlayerPostThink:

Code:
self.velocity_x = self.velocity_x * (1 - ( (self.ammo_nails * .0001) + (self.ammo_rockets * .001) ) ); self.velocity_y = self.velocity_y * (1 - ( (self.ammo_nails * .0001) + (self.ammo_rockets * .001) ) );

It works pretty good , except for when I jump.
It seems that the velocity in the air is affected much more than the velocity while on the ground.
self.velocity_z seems to be just fine. x and y seem to slow down 2-3 times as much while airborne. I can't figure this one out. Any help?
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Thu Sep 13, 2007 1:37 am Post subject: |

This would be because when you're in the air, your velocity for keypress is greatly reduced. (Meaning when you're on the ground you can move fast enough when holding down a direction key to offset your reduction code. However, when you're in the air, this is cut almost to zero.)
You'll have to figure out a way of just simply limiting it so that it doesn't exceed a certain figure. i.e. figure out the player's maximum normal velocity, then apply your weight stuff, and finally lock the x and y self.velocity to not exceed the x and y of your limiting figure.
_________________
"Roboto suggests Plasma Bazooka."

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Thu Sep 13, 2007 2:54 am Post subject: |

This code isn't happening every frame is it (e.g. in PlayerPreThink or PlayerPostThink or one of the functions they call?). Because if so, it's also framerate dependant. If you have a slower computer, you will move faster (fewer reductions per second), a faster computer and you will move slower (more reductions per second).
I suggest doing what Dr. Shadowb0rg recommended in his last reply.

Back to top |

redrum Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York |

Posted: Fri Sep 14, 2007 2:28 pm Post subject: |

What do these lines of code mean?

Code:
if (!(self.flags & FL_ONGROUND))

Code:
if ( !(self.flags & FL_JUMPRELEASED) )

_________________
Welcome to the Overlook Hotel 69.113.123.178:27500

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Fri Sep 14, 2007 3:56 pm Post subject: |

redrum wrote:
What do these lines of code mean?

Code:
if (!(self.flags & FL_ONGROUND))

Code:
if ( !(self.flags & FL_JUMPRELEASED) )

The first means: if I'm NOT on the ground.
The second means: if I haven't released the jump key
Remember that the ! is an operator for NOT.
_________________
"Roboto suggests Plasma Bazooka."

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group