- Home /
Question by
SavvaMadar · Oct 14, 2012 at 10:24 PM ·
child
On raycast hit spawn object and parent
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? Please modify my code for me, ALSO I NEED IT TO BE ANY OBJECT HIT WITH IT DONT GIVE ME AN ANSWER SAYING TO SPAWN THE OBJECT AS A CHILD TO ANOTHER OBJECT USING A NAME! I NEED IT TO BE WITHOUT USING NAMES!
Comment
Best Answer
Answer by dannyskim · Oct 14, 2012 at 10:38 PM
if(Hit.collider.tag == "Flesh")
{
var obj : Transform = Instantiate(BodyImpact,Hit.point,Quaternion.FromToRotation(Vector3.forward,Hit.normal)) as Transform;
obj.transform.parent = Hit.collider.transform;
}
Your answer
Follow this Question
Related Questions
Problem with Pause and Pause Menu Script 1 Answer
destroy child object 2 Answers
GetComponentInChildren(Renderer).active wont work? 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
HIDE CHILD script - help 3 Answers