- Home /
Instantiate Prefab At Collided Object?
How do I instantiate a prefab at the collided objects position, and not at the position of the object holding the collider and script?
Answer by smrt_co · Aug 28, 2013 at 12:46 PM
void OnCollisionEnter(Collision c)
{
Instantiate(prefab, c.gameObject.transform.position, someRotation);
}
Also, see this: http://docs.unity3d.com/Documentation/ScriptReference/Collision-contacts.html
Edit:
Trigger
void OnTriggerEnter(Collider c)
{
Instantiate(prefab, c.transform.position, someRotation);
}
Sorry, I edited the post while you were reading, but I guess that you found what you were looking for either way. :)
Yes I did. :D Is there any way to do the same thing but with a trigger too?
Edit: I'm a javascript user but C# is fine too I'll get it. :D
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Instantiated (clone of) prefab, doesn't trigger another object's collider when inside it. 2 Answers
i need to copy a list from the collided to the newly instantiated one individually . 0 Answers
Instantiate breaking at certain positions? 0 Answers
Detecting collisions between blocks? 3 Answers