|
I have a prefab i instantiate, and when i change its position and local position to 0,0 it doesn't seem to change in hierarchy view in editor. I have a debug system that prints out values to a gui text object and it says the local position before and after is 0,0. But in the editor it is a random huge value. Why would this be? I'm using this code to change its positions: This code works fine with no compile errors and print sout the location to the gui text object. Here is a screenshot of this in the editor window(I highlighted notable parts): There are no null reference exceptions and the script is on the gameobject i wnat to modify. Notice that the gameObjects's transform only has localPosition and not normal position. Why is this? It is not a child of another object....Just a prefab.
(comments are locked)
|
|
In you full script you have this code: But labelOfBuilder is a component on the same game object as the Builder script, so it moves the builder to that location, hence your changed coordinates. Nice catch! how did i forget that?? I forgot to attach it to a child gameObject for this part of my implimentation.
May 23 '12 at 12:16 AM
1337GameDev
Just one of those - when you've exhausted the obvious and you don't know the code you see it with different eyes :)
May 23 '12 at 12:44 AM
whydoidoit
(comments are locked)
|


My guess would be that something is changing it after your debug logging - where is that happening at the moment?
This script that's printing values, which object is it attached to?
If those two aren't the same object, confusion might result.
Nope. I don't modify the position of the gameObject anywhere else.... Here is my scripts on http://justPaste.it.
http://justpaste.it/108g
Hmmm, well your transform.localPosition.Set(0,0,0) probably isn't doing anything as transform.localPosition returns a copy of its position I believe. But clearly the position appears to be Vector3.zero in any case. Which makes sense as it has no parent right?