Hey guys,
So I’m working on what is essentially an AC-130 game and I’m trying to drop proximity mines onto the field that explode when the enemies are nearby. This is what I’ve got so far:
var proxMine : GameObject;
var targetObject: GameObject;
var shots : int = 0;
var maxShots : int = 2;
var proximity : float = 3;
var explosion: GameObject;
var explosionRadiusTest: GameObject;
function FixedUpdate()
{
if(Input.GetKeyDown("space") && shots < maxShots)
{
Instantiate( proxMine, Vector3( transform.position.x, transform.position.y, transform.position.z ), Quaternion.identity );
shots++;
}
else if (shots >= maxShots && Input.GetKeyDown(KeyCode.R))
{
shots = 0;
}
var dist = Vector3.Distance(targetObject.transform.position, transform.position);
if (dist < proximity)
{
Instantiate (explosion, Vector3(proxMine.transform.position.x, proxMine.transform.position.y, proxMine.transform.position.z), Quaternion.identity);
Instantiate (explosionRadiusTest, Vector3(proxMine.transform.position.x, proxMine.transform.position.y, proxMine.transform.position.z), Quaternion.identity);
Destroy(proxMine);
//Destroy(targetObject);
}
}
function getShots()
{
return shots;
}
God I hope that formatted correctly. Anyway, any help you guys could give would be grea. Thanks!