Set object's location to parent's

This one is kind of hard to explain. I want to instantiate an object (done that), set it as a certain object’s child (done as well) but now I want it to be in the same place as it’s parent (that would be 0,0,0 in the inspector). when i instantiate the game object i use

Instantiate (transform.position, transform.rotation);

but it spawn a few units up according to what seems to be to the Z position

here are screenshots:


the first one is of the object being instantiated (the one with the red dot) and the second on is when the object was instantiated when the instantiator’s position was around 6.3 units in the Z axis. here is the script is used.

using UnityEngine;
using System.Collections;

public class WeaponEquipper : MonoBehaviour {

	public GameObject StarterWeapon;
	public GameObject InstantiatedStarterWeapon;

	// Use this for initialization
	void Start () {

		StarterWeapon = GameObject.Find ("MonstercatChar").GetComponent<ExperimentalDeath> ().StarterWeapon;
	// Update is called once per frame
	void Update () {

			InstantiatedStarterWeapon = Instantiate (StarterWeapon, transform.position, transform.rotation) as GameObject;

			InstantiatedStarterWeapon.transform.parent = transform;



note that when i instantiated the object i destroyed it’s children, and that the object being instantiated is the object with the red dot. thanks for any help !

if its already a child of the object you want it to be aligned with, set the localPosition of the new object to 0,0,0.

newObject.transform.localPosition = new Vector3(0,0,0);