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, 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.
Answers and Comments
No one has followed this question yet.
Spawnning an object other than primitive makes the function run again and again
[RESOLVED] lost lighting information on baked prefabs when instantiated
Array values changing after gameObject is instantiated from prefab
Game object instantiated and added to list but the change in capacity shows that 4 game objects have been added to the list?
Instantiating Custom Prefabs