21.02.2014, 23:31
I did this the forward way, by adding spread to serversided bullets.
Getting the actual spread from the gta guns would work the same way, just backwards. Comparing the player pos and bullet target already is the right way. Take the vector between them and compare it to the aim vector of the player (the aim vector is NOT the same as the camera vector, there are some functions to calculate it here that are precise enough, search the forum for that. I had problems with extreme height angles close to +/-90°, did some really crazy math stuff to minimize the error). Then calculate the angles between those two vectors and you got the spread.
Getting the actual spread from the gta guns would work the same way, just backwards. Comparing the player pos and bullet target already is the right way. Take the vector between them and compare it to the aim vector of the player (the aim vector is NOT the same as the camera vector, there are some functions to calculate it here that are precise enough, search the forum for that. I had problems with extreme height angles close to +/-90°, did some really crazy math stuff to minimize the error). Then calculate the angles between those two vectors and you got the spread.