Attach object as child using code

if(Hit.collider.tag == “Flesh”){var obj : Transform = Instantiate(BodyImpact,Hit.point,Quaternion.FromToRotation(Vector3.forward,Hit.normal)) as Transform;
}

**My goal is to create object called BodyImpact on collision of an object with the tag called Flesh, this works but for some reason I can’t get that BodyImpact object to become a child of the object hit… How do I do that? (JS) **

BodyImpact.transform.parent =parent.transform;

It’s as simple as that!

Instead of parent, use the game object that you have made that will be parent,free example bodyParent.