.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Finding angle at which a grenade hits a wall (http://forums.bots-united.com/showthread.php?t=1637)

two_masks 10-05-2004 22:04

Finding angle at which a grenade hits a wall
 
Hi yet again everyone,

Sorry for the deluge of questions recently. I'm now trying to determine the angle at which a grenade hits a wall. I have the grenade entity, but I'm not sure how to get the angle of a wall it hits relative to the grenades vector of motion.

Can someone help me with this? Thanks a lot.

@$3.1415rin 10-05-2004 22:20

Re: Finding angle at which a grenade hits a wall
 
this may help you :

if you have two vectors, the dotproduct of the normalized vectors ( length is 1 ) of both ( dotproduct is sum over the products of the components x(i)y(i) ) is the cosine of the angle

the cool thing about it is that this simple stuff is working in n-dimensional vector spaces 8) ( at least on kanonical bases )

€ : argh, what did I write
€^2: LA sucks btw ... at least the nontrivial stuff ... but somewhen you'll call everything trivial, so there is still hope

stefanhendriks 10-05-2004 22:21

Re: Finding angle at which a grenade hits a wall
 
euh, what do you want to do with that information? If you want to let bots avoid grenade's , you can scan within a specific area for grenades and let bots just react on the grenade vector. Or, even more neat is to store it as a possible danger vector, then keep track if it gets closer , and if it does, then react on it.

two_masks 10-05-2004 22:30

Re: Finding angle at which a grenade hits a wall
 
Well, I'd like my bots to run away from the grenade if it looks like it's going to bounce off a wall at a sharp angle, or run towards it if it looks like it's going to bounce at a shallow angle. I'm building these bots for a prototype simulation, not for real CS play, and this behavior is an approximation of diving for a grenade to throw it back if it's not bouncing around too much, or just running away if it doesn't look like it's catchable. Of course the bots won't actually be able to pick it up, but the important thing to show is that they "thought" to run after it in some cases. I chose the angle thing since CS doesn't let you vary the strength of your toss, so I had to choose another metric to base the decision on.

Any other tips? The dotproduct is useful, but the problem is that I don't have two vectors, just the edict of the grenade. If it's possible to get a vector for the wall, let me know!

@$3.1415rin 10-05-2004 22:34

Re: Finding angle at which a grenade hits a wall
 
do a traceline along the estimated trajectory and then, if you hit the wall, the traceline function returns also a face normal of the wall

Pierre-Marie Baty 11-05-2004 04:51

Re: Finding angle at which a grenade hits a wall
 
s/"along the estimated trajectory"/"using the grenade edict's velocity"

@$3.1415rin 11-05-2004 09:38

Re: Finding angle at which a grenade hits a wall
 
what are you trying to say pierre ? what's that kind of syntax ?

Pierre-Marie Baty 11-05-2004 12:49

Re: Finding angle at which a grenade hits a wall
 
ah... it's Unix syntax :) "awk", I think (or is it "sed" ? can't remember).
means "replace item 1 with item 2"
used like this (on a forum or on Usenet) it means that by saying item2 you were probably meaning item1
That was just to make thins more clear :)

Whistler 11-05-2004 13:45

Re: Finding angle at which a grenade hits a wall
 
' s/"along the estimated trajectory"/"using the grenade edict's velocity" '
I first thought it's CCED and really surprised (may be unknown to you, but it's a very common text editor in mid-1990s in China - as well as WPS) :)
Looks like Zhu Chongjun has stole the awk syntax

@$3.1415rin 11-05-2004 19:45

Re: Finding angle at which a grenade hits a wall
 
but I meant estimated trajectory, since most grenades do not fly a straight line ... :)

but estimated trajectory can still be a straight line, nevertheless ...


All times are GMT +2. The time now is 15:49.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.