GameObject changes position after play on Unity

1

I have the following scenario:

Theotherobjectsweredisabledonlytodemonstratetheproblem.Ithinkthatdisablingthemdoesnotinfluencethegame,right?

SeewhathappenswhenyouclickplayonUnity:

NotethattheobjectGroundandGround_2werechangedtoposition(0,0)inrelationtothecamera(yes,thespritepivotisBottomLeft,soitdoesnotstaycentered)

Seetheconfigurationoftheobjectsintheinspector:

Background

Camera

CameraScript

usingUnityEngine;usingSystem.Collections;publicclassCameraSettings:MonoBehaviour{privatefloattargetRatio=9f/16f;//UsethisforinitializationvoidStart(){Cameracam=GetComponent<Camera>();cam.aspect=targetRatio;}}

Ground(the3objectsarethesame,havebeenduplicatedsotheattributesintheinspectorarethesame):

NoticethatGround,Ground_2,andGround_3areprefab.IcreatedanemptyGameObject(andaddedRectTransform,Rigidbody2Dasabove)andwithinthatGameObjectIaddedasprite(GroundSprite)withthefollowingsettings:

After the above action, I dragged the GameObject to a prefab and then removed the GameObject from the scene, later dragged the prefab to the scene 3 times, generating the 3 elements that make up the ground (Ground, Ground_2 and Ground_3) and logo then I went on the menu in "GameObject> Break Prefab Instance" to be able to edit them without modifying my prefab.

Yes, it was a big mess, but I think the problem is not that it's dragging things around, right?

What's wrong with the game? Can it be program cache? Installation with problem? What will it be?

    
asked by anonymous 22.08.2015 / 18:40

1 answer

1

It seems to be a bug starting with version 5.1.2 of Unity: link

According to the user, it resolved as follows:

  

I solved the problem. It was caused by the rigidbody2Ds position constraints. I confirmed this by having a few clones of the gameobject put to the scene and ticked off the constraint off one of them.

     

When the bug appeared again, only the gameobjects with the position Y or X frozen was reseted to the (0,0,0) position. I ticked the constraint back on and that gameobject was also moved to the zero position after that.

     

I'm not sure if that's how the constraints are supposed to work or is it a bug. But anyway that was causing the random behavior.

    
31.08.2015 / 18:32