Point light moves to origin
My code adds several point lights as follows:
GameObject lightObject = new GameObject(("Light_"+obj["Name"].str));
lightObject.AddComponent<Light>();
lightObject.GetComponent<Light>().type = LightType.Point;
lightObject.GetComponent<Light>().color = Color.white;
lightObject.GetComponent<Light>().intensity = 0.15f;
lightObject.GetComponent<Light>().range =15.0f;
lightObject.GetComponent<Light>().renderMode = LightRenderMode.ForcePixel;
lightObject.transform.position = new Vector3(xpos, zpos, ypos);
This runs on start(), and it works fine in unity 4, the lights are getting in their position as planned.
When I migrate the code to Unity 5 all my lights are in the origin, instead their assigned position by code.
Am I missing something for Unity 5?
Answer by V-O-D-Games · May 09, 2016 at 06:45 PM
Hi I haven't compiled your code yet or read it in deapth but I would create a varable for your vector 3 positions and instead use them. Hope this helps I will get back to you after I've fully tested the script
Your answer
Follow this Question
Related Questions
Script for activating next GameObject after first one has been found/tracked (Vuforia) 1 Answer
space shooter tutorial issue "Ending the game" unity 2018.2 b 1 Answer
Getting wrong value of variable 1 Answer
I need help working out a C# script with error CS0120 1 Answer
New Hierarchy Son Script 0 Answers