Game Development Reference
In-Depth Information
function Start () {
_rocketUI = FindObjectOfType(typeof(RocketUI));
}
public function Fire( reloadTime : float ) {
if (Time.time > (reloadTime + lastShot) &&
ammoCount > 0) {
var rocketPrefab : ConstantForce =
ConstantForce.Instantiate(rocket, transform.position,
transform.rotation) as ConstantForce;
rocketPrefab.relativeForce = new Vector3(0, 0,
speed);
smoke.Play();
//We ignore the collision between rocket and
character
Physics.IgnoreCollision(rocketPrefab.collider,
transform.root.collider);
//Get the last shot time
lastShot = Time.time;
//Decrease the bullet
ammoCount--;
_rocketUI.UpdateUI(ammoCount);
}
}
public function Reload () {
ammoCount = 20;
_rocketUI.UpdateUI(ammoCount);
}
// C# user:
using UnityEngine;
using System.Collections;
Search WWH ::




Custom Search