[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Smooth Rotation And Rotate to Specific Degree

Smooth Rotation And Rotate to Specific Degree

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Smooth Rotation And Rotate to Specific Degree

Postby Junrall » Thu Nov 12, 2015 9:58 am

Hello all,

I'm dinking around with DP and it's bot spawning function spawnclient().

Does anyone know of a way to easily use DP to smoothly rotate a bot's yaw to a specific degree? I'm not familiar with DP, so I might be missing something in the dpextensions.qc file.

I have been experimenting with a few things:
self.v_angle_y = self.v_angle_y + 5 gives me very smooth rotation, which is what I want but I have no idea how to stop the rotation at a specified yaw degree.

self.angles_y = self.angles_y - 35 rotates the bot 35 degrees to its right, but its instant and not a smooth turn.

I feel like I'm kinda on the cusp. Any guidance would be appreciated.

Perhaps something like this? (nvm... I tried this and it didn't work. lol)

if (self.angles_y != 35)
self.v_angle_y = self.v_angle_y + 5;
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Re: Smooth Rotation And Rotate to Specific Degree

Postby Spike » Fri Nov 13, 2015 1:34 am

self.ideal_yaw = vectoangle(self.enemy.origin - self.origin);
self.yaw_speed = 5;
changeyaw();
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Smooth Rotation And Rotate to Specific Degree

Postby Junrall » Fri Nov 13, 2015 6:59 am

Thanks for the response Spike,

Based on what you shared, I had thought that the following would work, but it did not. (self.ideal_yaw is a float and would not accept vectorangles directly.)

vector tempvec;

tempvec = vectoangles('0 200 0' - self.origin);

self.ideal_yaw = tempvec_y;
self.yaw_speed = 5;
ChangeYaw();


Knowing that self.ideal_yaw is a float, I would assume that I could just plug a value directly into self.ideal_yaw to rotate the bot.... I was wrong, it did not work.

self.ideal_yaw =75;
self.yaw_speed = 5;
ChangeYaw();


Sorry for the basic questions and not seemingly to have a clue. It's been years since I last played with this. I once had a basic understanding of this, and now I remember nothing!
Last edited by Junrall on Sun Nov 15, 2015 7:38 am, edited 1 time in total.
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Re: Smooth Rotation And Rotate to Specific Degree

Postby Junrall » Fri Nov 13, 2015 7:02 am

Sorry,

tempvec = vectoangles(self.enemy.origin - self.origin);

should be

tempvec = vectoangles('0 200 0' - self.origin);
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Re: Smooth Rotation And Rotate to Specific Degree

Postby Spike » Fri Nov 13, 2015 7:54 am

vectoyaw sorry, at least if you're after just yaw angles.

//determine angle. note that vectoyaw is mostly equivelent to atan2(dir_y,dir_x)
float dir = targetpoint - entorigin;
newangle = vectoyaw(dir);
//figure out the change
float change = newangle - oldangle;
//and make sure the range is sane - specifically adjust it so it can cope with the fact that angles wrap.
while (change > 180)
change = change - 360;
while (change < -180)
change = change + 360;
//now clamp the change to the maximum angle change allowed maxchange could be changepersec*frametime if your entity is thinking at a variable framerate.
if (change < -maxchange)
change = -maxchange;
if (change > maxchange)
change = maxchange;
//and calculate the new angle.
newangle = oldangle + change;

if you want to interpolate between an old angle and a new angle, you can precompute the initial newangle, remove the maxchange stuff, and then tweak that last line to:
newangle = oldangle + change*(time-oldtime)/(nexttime-oldtime);
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Smooth Rotation And Rotate to Specific Degree

Postby Junrall » Sun Nov 15, 2015 7:26 am

Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Re: Smooth Rotation And Rotate to Specific Degree

Postby r00k » Mon Nov 16, 2015 10:45 am

r00k
 
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Smooth Rotation And Rotate to Specific Degree

Postby frag.machine » Mon Nov 16, 2015 12:06 pm

I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2120
Joined: Sat Nov 25, 2006 1:49 pm

Re: Smooth Rotation And Rotate to Specific Degree

Postby Junrall » Tue Nov 17, 2015 6:35 am

Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest