Search Unity

Issue with Transform.Position on different platforms (Windows, Mac OSX, iOS)

Discussion in 'Physics' started by mkrana, Mar 27, 2015.

  1. mkrana

    mkrana

    Joined:
    Mar 27, 2015
    Posts:
    4
    I have basketball as a gameobject. I added a ball shoot 'legacy animation' on it. On 21st frame of the animation I generate a physics rigidbody which got the position (Transform.Position) from the Bone within the ball. The rigid body will act as my physics ball from here on.

    The problem is that when I am assigning the position of the previous ball to physics ball as spawn position, the vector3 values of the position are different on different platforms (Windows, Mac and iOS). In short, Transform.Position is returning different values on different platforms (Windows, Mac OSX, iOS).

    Sample count - 2
    Sample values -

    Mac OSX:
    x -11.48562 - y 2.482513 - z 0.6287599
    x -11.45367 - y 2.468241 - z 0.6918476

    WINDOWS :
    x -11.45818 - y 2.469951 - z 0.68388
    x -11.4559 - y 2.469079 - z 0.6879336

    DEVICE :
    x -11.41093 - y 2.448512 - z 0.771808
    x -11.41094 - y 2.448518 - z 0.7717882

    This is causing problems as the physics ball path varies on the slight change in position.

    Anyone else can confirm the same if this is a unity issue?

    Why is the position different on different platform on the same frame when playing the same animation?

    Unity Version: 4.5.4
     
  2. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    have you tried getting the position of the gameobject's transform instead?
     
  3. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    Unity advances frame rate as fast as possible. The "21st frame" of your animation might be the 21st frame of Unity since the level started, or the 100th, or the 10th. If the Unity frame rate is much faster than your data, it'll interpolate between, and if it's slower it'll skip.

    In general, don't expect deterministic behavior out of either Unity or the physics engine, especially across platforms.
     
    Nanako likes this.