- Home /
 
Object position values glitch?
Is this a glitch within Unity itself or am I crazy? This simple code prints out the XYZ location of the player:
 var Player : GameObject;
 function Start () {
     Player = GameObject.Find("My Player");
 }
 function Update () {
     Print(Player.transform.position);
 }
 
               In this code, "My Player" is simply the default Unity FPS controller character. When I run this, I keep my player character still. The X and Z values remain unchanged like I expect, but the Y value fluctuates randomly!
Why would that be? My character is not moving at all!
This is driving me mad! Any ideas?
Answer by Muuskii · Sep 26, 2012 at 04:05 AM
Gravity is causing it to move, collision reflects it back to it's former position. Floating point errors do the rest. I wouldn't be too worried, it's harder to get virtual objects to sit still than toddlers.
Sometimes you have to nail them to the ground. I have no solution to Unity objects though. . .
Yup. I don't remember if it was me who turned Gravity on for $$anonymous$$y Player object, but turning it off fixed the problem.
I knew it would be simple. Thank you.
Your answer