Disable Light,ParticuleSystem and gameobject from the parent?
Hello,Im trying to create a script that will enable a light, a particule System(Or Acces The Emmiter) And a Gameobject wich are child of the gameobject that contain the script.
I got those errors:
1.Cannot implicitly convert type UnityEngine.Transform' to UnityEngine.ParticleSystem' 2.Cannot implicitly convert type UnityEngine.Transform' to UnityEngine.Light' 3.Cannot implicitly convert type UnityEngine.Transform' to UnityEngine.GameObject'
Here's the script:
using UnityEngine;
using System.Collections;
public class ItemLightLifetime : MonoBehaviour {
public int LifeTime = 300;
private GameObject LightZone;
private Light LightSource;
private ParticleSystem Particule;
// Use this for initialization
void Start () {
SetReferences ();
InvokeRepeating ("timeisgoingon", 0f, 1f);
}
// Update is called once per frame
void Update ()
{
}
void timeisgoingon()
{
if (LifeTime > 0) {
LifeTime -= 1;
}
else
{
TurnOffLight ();
}
}
void TurnOffLight()
{
if (LifeTime == 0)
{
LightZone.SetActive (false);
LightSource.enabled = false;
Particule.IsAlive (false);
}
}
void SetReferences()
{
LightZone = transform.Find ("LightZone");
LightSource = transform.Find ("LightSource");
Particule = transform.Find ("Particule");
}
}
Your answer
Follow this Question
Related Questions
Particle Simulate Local And World Space question 1 Answer
Performance question: Is it better to Instantiate particle systems OR use same particle system? 1 Answer
Unable to enable/disable Particle System emission in script 2 Answers
Particle lights with flares 1 Answer
ParticleSystem.Particle[] gives error 0 Answers