.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Having a bot face one way, while moving another
Old
  (#1)
Maleficus
Member
 
Maleficus's Avatar
 
Status: Offline
Posts: 1,054
Join Date: May 2004
Location: Planet Earth
Default Having a bot face one way, while moving another - 20-05-2004

Hellos!

I'd like to know what you guys think would be the best (cheapest, fastest) way to have a bot move in one direction, while looking in another.

Please understand that my question is for a Quake 3 engine based game (so any examples will have to be in C ).

ATM, I basically just set the bots ucmd.angles to point to where ever its current goal is (waypoint, enemy, friend), and then set its ucmd.forwardmove to max (i.e. it turns to its goal, then runs forward).


Dum Spiro Spero


  
Reply With Quote
Re: Having a bot face one way, while moving another
Old
  (#2)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: Having a bot face one way, while moving another - 20-05-2004

There is the body/facing angles and then there is the movement direction (forwardmove, sidemove, etc.).

Just set the facing direction to one angle and set the movement direction based on a different angle (or vector). Using a movement angle would make things easy since you could get the forwardmove and sidemove values just by using sin() and cos() on the movement angle.

botman
  
Reply With Quote
Re: Having a bot face one way, while moving another
Old
  (#3)
Maleficus
Member
 
Maleficus's Avatar
 
Status: Offline
Posts: 1,054
Join Date: May 2004
Location: Planet Earth
Default Re: Having a bot face one way, while moving another - 20-05-2004

Quote:
Originally Posted by botman
Just set the facing direction to one angle and set the movement direction based on a different angle (or vector). Using a movement angle would make things easy since you could get the forwardmove and sidemove values just by using sin() and cos() on the movement angle.

botman
Thx for the quick reply!

However, one problem, my 3D math skills suck.

How would I get those forwardmove, sidemove values?


Dum Spiro Spero


  
Reply With Quote
Re: Having a bot face one way, while moving another
Old
  (#4)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Having a bot face one way, while moving another - 20-05-2004

dunno about quake3, maybe you can even set the movement direction by using a vector pointing to that direction or according pseudo polar coordinates ( 2 angles )


  
Reply With Quote
Re: Having a bot face one way, while moving another
Old
  (#5)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: Having a bot face one way, while moving another - 20-05-2004

sin() is used to find the Y axis direction and cos() is used to find the X axis direction (or if your axes are flipped, sin() for X and cos() for Y).

You would need to keep a bot variable (not in the edict) for the "direction angle" you want them to go. You can keep that in degrees if you aren't comfortable with radians (which is what sin() and cos() use as arguments). Let's say you call your "direction angle" variable 'a_dir' and you're keeping things in degrees (0-360). You could do something like this to set the forwardmove and sidemove values...
Code:
float radians = a_dir * 3.14159f / 180.f; // degrees to radians
float forwardmove = cos(radians);
float sidemove = sin(radians);
 
// now scale the forwardmove and sidemove values up by the
// speed you want to use since sin() and cos() return values
// between -1 and 1...
forwardmove = forwardmove * 100.0f;
sidemove = sidemove * 100.0f;
 
// then call the engine "move" function with your forwardmove
// and sidemove values as usual
Notice that you could move forward/backware at different speeds than sideways (by changing the 100.0f in the above code), you doing this would cause your movement angles to be skewed.

botman

Last edited by botman; 20-05-2004 at 16:13..
  
Reply With Quote
Re: Having a bot face one way, while moving another
Old
  (#6)
Maleficus
Member
 
Maleficus's Avatar
 
Status: Offline
Posts: 1,054
Join Date: May 2004
Location: Planet Earth
Default Re: Having a bot face one way, while moving another - 20-05-2004

Thx Botman!

I'll give that info a try


Dum Spiro Spero


  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com