Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Grenade Angles

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any way to calculate the angle for a certain range?? This is my first time using C++ so I have no idea how to output the stuff req''d to find it (ie distance of enemy + experimental angle -> how far off)...I''ve been using a nested if structure (which works kinda okay except when it blows my bot up).. I understand that I am the enemy, but for the sake of helpfulness?? hehe? -------

Share this post

Link to post
Share on other sites
I made a polynomial to approximate it.. basically I tested the range at a variety of angles, and made a cubic best fit line in Excel... this was the result:

0.0002f*x^3 - 0.0622f*x^2 + 3.6339f*x + 49.691f

Note that sometimes the grenades bounce. this is only an estimate of the range. (x is the launch angle)

EDIT: obviously this gives the range for a given launch angle... you would need to inverse it, this is probably not good to do as it needs a cube/square root. You could obviously get a taylor expansion of the result.. or of course make a similar function for the inverse.

To output numerical info, I do this...

std::ostringstream output;
output<<(info to output here, to be converted to text);

So in your case, simply output the range of any grenade in view and it will appear in your bots speech output. To find out how you do this bit, read the readme. If you can't get it working.. then you probably need to work a bit more on your C++ skills before entering.

[edited by - dmounty on October 22, 2003 2:29:06 PM]

Share this post

Link to post
Share on other sites
Ahh... so that''s how it works...

Thanks for the equation, dmounty.. I''ll plug that in for my final version happily...

Best of luck finishing your bot! Looks impressive, and should rip if you code it all!!


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!