Help with self.velocity
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
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:
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?
- Code: Select all
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
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: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
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.
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.
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
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.
I suggest doing what Dr. Shadowb0rg recommended in his last reply.
- FrikaC
- Site Admin
- Posts: 1026
- Joined: Fri Oct 08, 2004 11:19 pm
What do these lines of code mean?
- Code: Select all
if (!(self.flags & FL_ONGROUND))
- Code: Select all
if ( !(self.flags & FL_JUMPRELEASED) )
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
-

redrum - Posts: 410
- Joined: Wed Mar 28, 2007 11:35 pm
- Location: Long Island, New York
redrum wrote:What do these lines of code mean?
- Code: Select all
if (!(self.flags & FL_ONGROUND))
- Code: Select all
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.
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest