- Home /
Using Instantiate on a Rigidbody rather than a whole GameObject
I can copy the Rigidbody of a prefab:
var r = Instantiate(missilePrefab.rigidbody);
but I can't set it on my object:
mymissile.rigidbody = r;
This is just an excerpt. The full story is that in some cases when I Instantiate my missile, I need to Destroy the rigidbody. I want to be able to recreate it, with it's properties set as they were before I Destroyed it.
I guess I'm looking for:
mymissile.AddComponent(r);
But there is no such function (AddComponent takes a string or a type).
Answer by Mike 3 · May 17, 2010 at 09:02 AM
You can't do it - the best you can do is copy the properties, then do a normal AddComponent(Rigidbody) and set the properties yourself
I agree with $$anonymous$$ike, add a new rigid body and then set its properties from the copy
Your answer
![](https://koobas.hobune.stream/wayback/20220613002134im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Prefabs not working properly 1 Answer
How do I instantiate a Prefab using a MenuItem? 1 Answer
Unespected rotation for Instantiate object 1 Answer
Variable of prefab has not been assigned 2 Answers