- Home /
Moving objects upwards in unity's editor-window, moves the same object automatically further on z-axis
Hi,
I think the topic explains itself.
I'm creating a 2D JnR. Main Camera is Orthographic.
The Collision works just fine so far as long as the z-position of my blocks (on which the player can stand) is between ~ -0.5 and 0.5. I put all blocks in a folder in the scene-hierarchy. The first (or origin) block was created with z position 0. All dublicated blocks on screen have the same properties, until I move them upwards (or downwards). Moving upwards increases the z position. And vice versa. Not proportional, only a little bit. But when a block reaches a certain height, z-position is 0.5. With these blocks, the player won't collide.
I could fix this by either putting a script on the specific blocks that lock the z position to 0 or adding some code to the collision query (like -> collide also when transform.position.z+1f) or something.
Both solutions would work. I tested them. But I guess both implementations are dirty work. I'd rather know the reason of this strange behavior and fix it, so that I can place the graphics wherever I like (with z = 0, always). Any ideas?
Thanks in advance!
EDIT:
Well, unfortunately, I can't provide any screenshot or video (confidentiality issues) of the current project. I'm trying to find a way to show it with another project/graphics later (or tomorrow). But I don't really think that it's necessary. At least in order to understand what i'm doing.
short summary: moving Graphics/GameObjects (with the mouse) in scene-view (in order to place them to a position I want them to have)
unwanted side effect: z position changes.
By moving them upwards (or increasing Y) z slightly increases, too.
What I forgot to mention is that the z-value jumps back after I try to manually enter "0" in Inscpector->Transform Position->Z and apply it.
But the spinners are set to Y and X only. Moving the object upwards only by the y-arrow doesn't work either.
I believed it has something to do with wrong settings or so (which I could post here of course. Any suggestions?).
Son, nothing about that "explains itself." You even talk about things that don't exist such as "folders in the scene-hierarchy". Show your work, maybe then someone can help debug it.
Answer by robertbu · Mar 18, 2013 at 04:20 PM
If you are doing what I think you are doing, you can drag by clicking on the end of an arrow rather than dragging on the object itself. For example by draging on on the green arrow your object will only move on the 'Y' axis. You can click on the spinner in the upper right corner of the scene view to change how you are looking at the scene making it easier to move only on a specific axis. If you have the spinner set to 'Y' up, and 'X' right or left, then if you drag directly on the object, you will not move on the 'Z' axis.
Thank you, robertbu. But that doesn't work either. The z-position still changes.
You need to do as @nxdavid suggest and provide a screen shot and a better explanation of what you are doing. If you use the spinner to orient on the 'X' 'Y' plane, and/or you only drag on an arrow (never within the bounds of the object), then I cannot see any way you would get Z movement out of an 'X' or 'Y' arrow drag.