How to Instantiate GameObject on top of collider? (C#

So I want to be able to instantiate a gameobject into the scene by the click of the mouse. I have it all figured out except one part, how would I make the instantiate ‘origin point’ to be the bottom of the gameobject, not the middle. Because when I spawn in objects, it looks like it’s instantiating them from the middle, making the object intersect and look weird. I just want to be able to place objects on top of other colliders, no intersecting involved.

Here’s my C# code:

void Update () {

		if (Input.GetMouseButtonDown(0)) {

			//Creates the raycast hit variable
			RaycastHit hit;

			//Creates the ray variable, set to origin at the center of the camera that the script is attached too
			Ray ray = camera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));

			//Starts the logic: if the raycast hits a collider, it will spawn (Instantiate) the prefab
			//obj is the prefab
			//hit.point is the location in which the ray collided

			if (Physics.Raycast(ray, out hit)) {
				if (hit.collider != null) {
					Instantiate(obj, hit.point, Quaternion.identity);

You can use an empty game object as a parent. The empty game object would be position at the place you want to move the pivot, and placement script would use the empty game object. There is also the SetPivot script in the Unity Wiki.

Since you have declared the prefab to instantiate, you can use it’s collider’s y size and y offset to find out at which y position the new gameObject has to be instantiated.