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:
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 Mike, add a new rigid body and then set its properties from the copy
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
No one has followed this question yet.
Can't instantiate bullets when calling shoot function in one script from another script.
C# setting instantiated prefab variables from another script.
Instantiate Clones Itself - Rather than Prefab
Can't remove instantiated prefab
Cannot assign prefab in Inspector?