-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathS_24022012_SMG.js
30 lines (25 loc) · 1.06 KB
/
S_24022012_SMG.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//---------------------------------------------
// Dan Welsh - 2012
// Danveria Acrade Gameplay scrpts
// SMG ver 0.01
//---------------------------------------------
var projectile : Rigidbody;
var initialSpeed = 400;//
var reloadTime = 0.25;//
var ammoCount = 300;//300 round in standard clip
private var lastShot = -10.0;
function Fire ()
{
// Did the time exceed the reload time?
if (Time.time > reloadTime + lastShot && ammoCount > 0)
{
// create a new projectile, use the same position and rotation as the Launcher.
var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);
// Give it an initial forward velocity. The direction is along the y-axis (its the axis that is facing forward) of the pistol's transform.
instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, initialSpeed, 0));
// Ignore collisions between the missile and the character controller
Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
lastShot = Time.time;
ammoCount--;
}
}