- Home /
Why does moving a game object transform work in the WebGL build but not the Windows build?
So I've run into a strange problem. I wanted to make a room where objects could be manipulated with the mouse cursor, but I discovered some objects wouldn't move. So I simplified the project into a single room with two buttons, one that moves the ceiling and one that moves the walls, using the following function:
public void MoveObjectUp(GameObject objectToMove) {
string dbMsg = "Original Position" + objectToMove.transform.position;
objectToMove.transform.position += new Vector3(0.0f, 1.0f, 0.0f);
dbMsg += "New Position" + objectToMove.transform.position;
Debug.Log(dbMsg);
}
So here's the weird thing. If I have the windows build set, only the ceiling can move, but not the walls, which happens in both the editor and the exe. However, if I build it in WebGL, it works in both the built html AND the editor! So changing the build is changing the game's behavior in the editor. Is there some bug in the windows build that's not in WebGL? The WebGL behavior should be the correct behavior.
The debug message indicates that the walls position is moving, but in the game it doesn't look like it is, like there's some disconnect between the mesh and the transform. Also, it seems like even for the windows build, the wall colliders are moving because I can walk through the wall after moving it high enough.
Answer by kyljnkns · Dec 08, 2015 at 12:02 PM
This problem has actually happened to me before. Chances are that the objects you can't move have Static Batching. You can read more about that here:
http://answers.unity3d.com/questions/1107699/why-does-moving-a-game-objects-transform-work-in-t.html
So for the objects you can't move, in the upper right of the object inspector, uncheck Static (there are several things that can be set to static, and "Batching Static" is the only one you actually have to uncheck). Hopefully that will fix your problem.
That was exactly it! That was certainly a simple, though a bit obscure solution. Thanks a bunch!