- Home /
Placing items on terrain in the editor
Hi, this has got to be an easy newbie question but I can't figure it out. I want to drag and drop entities from my Project into my scene, and have them show up on my terrain. But instead they show up some 100000000 miles away from the terrain object, and I have to manually pull them around for ten minutes until they sit on the terrain in the right spot. How do I get Unity to drop my stuff on the terrain? Or barring that, is there some way to say "put it where this other thing is"? I am having a really hard time positioning objects efficiently.
Answer by Eric5h5 · Mar 31, 2010 at 04:06 AM
If you drag objects into the hierarchy view, they will appear at 0,0,0. If you drag objects into the scene view, they appear some distance in front of the scene camera. You may therefore want to position the scene camera so that objects will appear in more convenient places. Also, if you hold down shift+command (shift+control on Windows) and drag the middle of the object, it will snap to the surface below.
(To update a two-year-old question:)
Another related newbie thing to know is that if you use the mouse wheel to move the editor camera, it DOESN'T actually move it. It just zooms the view in or out.
If you drop an item into the scene, it always appears just a bit away from the camera. But if you're zoomed way out, that may SEE$$anonymous$$ very far away. The fix is to zoom in with the mouse wheel.
(It would be nice if there was a way to see your current zoom level, but I haven't ever found it.)
Answer by twobob · Sep 29, 2014 at 07:13 PM
using UnityEngine;
using UnityEditor;
using System.Collections;
public class AlignWithGround : MonoBehaviour {
[MenuItem ("Tools/Transform Tools/Align with ground %t")]
static void Align () {
Transform [] transforms = Selection.transforms;
foreach (Transform myTransform in transforms) {
RaycastHit hit;
if (Physics.Raycast (myTransform.position, -Vector3.up, out hit)) {
Vector3 targetPosition = hit.point;
if (myTransform.gameObject.GetComponent<MeshFilter>() != null) {
Bounds bounds = myTransform.gameObject.GetComponent<MeshFilter>().sharedMesh.bounds;
targetPosition.y += bounds.extents.y;
}
myTransform.position = targetPosition;
Vector3 targetRotation = new Vector3 (hit.normal.x, myTransform.eulerAngles.y, hit.normal.z);
myTransform.eulerAngles = targetRotation;
}
}
}
}
Answer by JimNix · Mar 31, 2010 at 04:01 AM
An easy way to do this, is just to position your terrain at x=0, y=0, z=0. Then when you import a new object into your scene just type in the transform (position) box, 0 for each x, y and z co-ords. Tip: Once the object is placed at 0, 0, 0 press F, to quickly focus on it so you can move it around your terrain faster.
Your answer
Follow this Question
Related Questions
Terrain Tree Placement 0 Answers
Tree color variation 0 Answers
Remove Trees during runtime 1 Answer
Make a simple tree 1 Answer
How to raise a block from a Terrain 2 Answers