Game Development Reference
In-Depth Information
86.
Listing 49: Ray cast shooting scrip
First variables represent shooting properties mentioned earlier, which are maxRange ,
shootRange , verticalInaccuracy , horizontalInaccuracy , and power . The variable muzzle re-
present to the position and direction of the ray that is going to be cast. To apply the fire
rate, we need to store the time of the last ray cast. The variable lastShootTime is where we
are going to store this value. Each time a ray is cast, we generate two random values for the
angles of inaccuracy, and store these values in inaccuracyVector for later use. Inaccuracy
mechanism is going to be covered in details soon.
Search WWH ::




Custom Search