How to check if player "strafes" in QC
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
How to check if player "strafes" in QC
Hello,
I am currently stuck with a problem in QC.
I think this is a piece of cake for the most of you. My skills are poor.
This is what I want to do:
I want to check if and how fast the player currently is strafeing (moves sidewards).
If he is NOT strafing (or strafing with a very low velocity), I want to do "this", if he strafing with a higher velocity, I want to do "that".
Using DP.
In principle it is something like this, I guess:
Is there something like "self.velocity" but for strafing ?
Or how can I achieve what I want to with help of a workaround ?
The direction (strafe to left / strafe to right) independent to the world X/Y/Z coordinates, is dealed with -/+ ?
Thank you very much for your help.
I cannot find the solution by myself...
Seven
I am currently stuck with a problem in QC.
I think this is a piece of cake for the most of you. My skills are poor.
This is what I want to do:
I want to check if and how fast the player currently is strafeing (moves sidewards).
If he is NOT strafing (or strafing with a very low velocity), I want to do "this", if he strafing with a higher velocity, I want to do "that".
Using DP.
In principle it is something like this, I guess:
- Code: Select all
if (self.velocity >= 20)
do "that"
else
do "this"
Is there something like "self.velocity" but for strafing ?
Or how can I achieve what I want to with help of a workaround ?
The direction (strafe to left / strafe to right) independent to the world X/Y/Z coordinates, is dealed with -/+ ?
Thank you very much for your help.
I cannot find the solution by myself...
Seven
- Seven
- Posts: 301
- Joined: Sat Oct 06, 2007 8:49 pm
- Location: Germany
If you're using DP/FTE, you can just read the .vector movement; field to see if they're trying to move forwards (x), sideways/strafe (y), up/down(z).
The actual value is the speed the client wants to move at, typically be the same as cl_sidespeed (possibly negated, possibly larger than sv_maxspeed, also the client may 'ramp up' the value based on when the key was pressed/released).
So for DP:
if (self.movement_y < 0 || self.movement_y > 0)
strafing = TRUE;
For other engines, something like the following *may* work, but rockets will also affect it:
makevectors(self.v_angle);
side = normalize(self.velocity) * v_right;
if (side < -150 || side > 150)
strafing = TRUE;
Note that turning while running fowards can result in a sideways velocity relative to the new angle, thus such checks should be calculated based upon the change in velocity between the prethink and postthink functions, possibly clamping to slightly below sv_maxspeed so you can tell if they're still pressing a button. But that's just useless side knowledge as you're likely to use the DP extension instead. :P
The actual value is the speed the client wants to move at, typically be the same as cl_sidespeed (possibly negated, possibly larger than sv_maxspeed, also the client may 'ramp up' the value based on when the key was pressed/released).
So for DP:
if (self.movement_y < 0 || self.movement_y > 0)
strafing = TRUE;
For other engines, something like the following *may* work, but rockets will also affect it:
makevectors(self.v_angle);
side = normalize(self.velocity) * v_right;
if (side < -150 || side > 150)
strafing = TRUE;
Note that turning while running fowards can result in a sideways velocity relative to the new angle, thus such checks should be calculated based upon the change in velocity between the prethink and postthink functions, possibly clamping to slightly below sv_maxspeed so you can tell if they're still pressing a button. But that's just useless side knowledge as you're likely to use the DP extension instead. :P
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest