Game Development Reference
In-Depth Information
1. using UnityEngine;
2. using System.Collections; 3.
4. public class RaycastShooter : MonoBehaviour { 5.
6.
//How far can each bullet travel
7.
public float maxRange = 100;
8.
9.
//how many seconds to wait between two consecutive shoots
10.
public float shootRate = 0.1f;
11.
12.
//vertical inaccuracy in degrees
13.
public float verticalInaccuracy = 1;
14.
15.
//horizontal inaccuracy in degrees
16.
public float horizontalInaccuracy = 1;
17.
18.
//Bullet damage from zero-distance
19.
public float power = 100;
20.
21.
//Possition and direction of casted rays
22.
public Transform muzzle;
23.
24.
//Last time shooting is performed
25.
float lastShootTime = 0;
26.
27.
//Store last inaccuracy vector
28.
Vector2
inaccuracyVector;
29.
30.
void Start () { 31.
32.
}
33.
34.
void Update () { 35.
36.
}
37.
38.
//Shoot a bullet using ray cast
Search WWH ::




Custom Search