moving a transform by 10 but it goes exra...

this has me totaly stumped.

im telling my camera to move down 10 like so:

function initCam()
{
	cam.transform.position.y = -10;
}

and for some reason when i test the app it goes from 0(its starting Y position) to -11.10805. i cant imagine why it would blatantly ignore what i have written in the script.

here is how its called:

function OnGUI () 
{
	if(totalTargets == 1)
	{
		if (GUI.Button(Rect(Screen.width*.1, Screen.height*.45, Screen.width*.15, Screen.height*.05), "Initialize"))
		{
			initCam();
			for(t in TargetedTargets)
			{
				if (t == true)
				{
					targets
.initNow();
    				}
    				c++;
    			}
    			c=0;
    		}
    	}
    }


side note: when i try to put it back to 0 using cam.transform.position.y = 0; it goes to -1.108051 instead. so far this is the first piece of code for moving the camera in this project. so it cant be any interference from any other scripts.


- forgot my unity was out of date, could be some kind of error. i'm going to update and restart my PC or something, see if that fixes it.

Hi Hardmode2236,

I recently lost some hair with this same issue… I was pulling my hair out, trying to figure out what the #)*(WGN was wrong with my coding…

It turned out that “After” I started playing my scene, the position of the object that I was moving with transform, actually was changed from where I thought it was.
It was a child object of a larger prefab, if I remember right.

So, it went like this: Object’s transform y position was set at 0.
When I clicked “play” (that button) in the editor, I then went to the inspector, and saw my object’s (the one I’m transforming) position (y) was not at 0 anymore, due to the placement of the parent object/prefab.

So, try to check and see if your object’s run-time position is actually adjusted after the scene starts up. :slight_smile:

Hope this helps.