Search Unity

Transform position changing on Play

Discussion in 'Physics' started by ParityClaws, Aug 1, 2015.

  1. ParityClaws

    ParityClaws

    Joined:
    Aug 1, 2015
    Posts:
    15
    Hi All,

    Newbie here so sorry if I say something that doesn't quite make sense.

    I have a problem with Unity in which my transform position of multiple objects is changing when I hit Play in Unity.

    I have a stack of cubes arranged in a tower formation and have triple checked their x and y coordinates, the problem arises when I hit Play. The Y coordinates of all the cubes changes by 0.000014 and the X coordinates change by 0.000038, both in the positive direction. This is the typical instance, which although is bewildering, not a huge problem. Sometimes when I load my project, the X and Y coordinates will continually shift until the tower falls down, and the only way to fix this, is to restart Unity, after which, the former behaviour is seen.

    Any ideas what would cause this and how I would go about fixing it?

    edit:

    Found the issue, it's simply just floating point imprecision, sometimes when starting unity the float is out by enough to affect the physics of the tower it starts on a slow but constant movement and eventual collapse of the tower. I should be able to fix it by rounding the floats to whole numbers at run-time.
     
    Last edited: Aug 3, 2015