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 post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Instantiate Prefab Array with ID
After instantiating an instance of a prefab and changing the value of a variable in a script attached to the prefab, that value is lost
Assign same value to multiple instances of the same prefab
Can't access enum property of an instantiated prefab.