Before updating to Windows 10 you may need to return your Pro license. More information here

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:


But there is no such function (AddComponent takes a string or a type).

more ▼

asked May 17, 2010 at 08:07 AM

avatar image

7.8k 68 103 116

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered May 17, 2010 at 09:02 AM

avatar image

Mike 3
34.6k 28 156 319

I agree with Mike, add a new rigid body and then set its properties from the copy

May 17, 2010 at 09:14 AM spinaljack
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: May 17, 2010 at 08:07 AM

Seen: 1746 times

Last Updated: May 17, 2010 at 08:07 AM