Question by
Hunika124 · Feb 02 at 08:58 PM ·
scripting problemscript.beginnerhow
Light not instantiate after a time
Hi! I have a little problem again. I wrote a script, but it wont work. So the script is doing after 5 minutes a spotlight instantiates. now, it wont instantiate. Theres no errors, nothing. Please help
using UnityEngine;
public class streetlampscript : MonoBehaviour { void Update() {
GameObject lightGameObject = new GameObject("The Light");
float time = 0;
time += Time.deltaTime;
if (time > 1 * 5) { Light lightComp = lightGameObject.AddComponent<Light>();
}
// Set the position (or any transform property)
lightGameObject.transform.position = new Vector3(0, 5, 0);
}
}
Comment
Your answer
Follow this Question
Related Questions
error CS0246 1 Answer
How can I improve this code? 1 Answer
Scripts Interfering With Each Other 1 Answer
Displaying Properties from Revit in Unity VR 0 Answers
How to add animations to character ? 0 Answers