Hello!
I am trying to create a smoke grenade but i cannot access the gameobject ‘SmokeCap’
‘SmokeCap’ is a child object of SmokeGrenade, and it has a particle emitter that i want to turn on after 6 seconds but the variable GrenadeMuzzle that i created on line 6 returns null instead of returning an object.
Here is my JavaScript
#pragma strict
var GrenadeTime = 0f;
private var oneSecond = 0.001f;
var duration : int = 20;
var despawnTime : int = 60;
var GrenadeMuzzle = GameObject.Find("SmokeCap");
function Start () {
}
function Update () {
print(GrenadeMuzzle);
GrenadeTime += oneSecond + Time.deltaTime;
print("GrenadeTime: " + GrenadeTime);
if (GrenadeTime >= 6) {
particleEmitter.emit = false;
GrenadeMuzzle.particleEmitter.emit = true;
}
if (GrenadeTime > duration + 6) {
GrenadeMuzzle.particleEmitter.emit = false;
}
if (GrenadeTime > despawnTime) {
Destroy(this.gameObject);
}
}