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.
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).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
No one has followed this question yet.
How to instantiate in self position.
How can I instantiate more prefabs as the score increases?
Prefab script to effect the unique instance
How can customize which prefabs are instantiated in a grid?
How to tell a prefab to instantiate itself?