Hello everyone! When dragging/dropping a prefab or GameObject to the scene, it tends to have a random z-value. I was wondering if it was possible to force every prefab, GameObject, etc. that is dragged from the Project view to the Heirarchy or Scene to have a specific z-value for Position. Is this possible?
FYI, this is for a 2D game, where the z-value determines where an object is in front of or behind other objects (so having a consistent “starting point” goes a long way).
Well if its a rigid body I think you can possibly set the z axis in the prefab to zero. and then in the prefab lock Z axis. That might force all prefabs dragged to keep the prefabs Z axis of zero (or whatever number)
the constraints are under rigidbody.
I myself dont know of anyway to put constraints on just a transform. At least not in the editor, could you script one up easy but it’d only go into affect once you began the game.
The objects that you’re dragging from the Prefab and placing into the scene are going to have a Z-Value relative to the original Z-Value of the Prefab. In order to get everything on the same Z-Value plane, you need to make sure to “Reset” the position of the Prefab before dragging items into the scene from it.
All the items will have different Z-Values (as well as X and Y values) depending on what the coordinate values of the original Prefab are. So make sure to reset your Prefabs to the origin before dragging objects from it into your scene.