NOTE: Detonator is a Unity explosion Prefab. BEWM! ![]()
I got this error:
GameMain.js is this:
var detailLevel : float = 1.0;
public var currentDetonator:GameObject;
var explosionLife : float = 10;
function Update () {
if (Input.GetMouseButtonDown(0)){
SpawnExplosion();
}
}
function SpawnExplosion()
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 1000))
{
var offsetSize = currentDetonator.GetComponent("Detonator").size / 3;
var hitPoint = hit.point + ((Vector3.Scale(hit.normal, Vector3(offsetSize,offsetSize,offsetSize))));
var exp : GameObject = Instantiate (currentDetonator, hitPoint, Quaternion.identity);
exp.GetComponent("Detonator").detail = detailLevel;
}
Destroy(exp, explosionLife);
}