Clone a body

Topics: Developer Forum
Sep 14, 2011 at 10:53 PM

Good day,

A) There used to be a way to clone a body and geom back in 2.0. I think it was something like BodyFactory.CreateBody(body);

Is there such thing in 3.3 ? Or is there an alternative to clone a body ?

 

B) Also, is it possible to create a body without adding it to a world ? That also used to be possible in 2.0. 

I would like to be able to first create a body, then assign it to a world eventually. 

Ex:

 

Body body = BodyFactory.CreateRectangleBody(width, height, density...)

// Do some stuff since the world is not created yet.

body.World = someWorld;

Thank you for your help

 

Sep 17, 2011 at 5:47 PM
Edited Sep 17, 2011 at 5:48 PM

idk about a) but for b) you can create the body and disable him and enable him if you need him

Edit: oh you want to create it if you have no world :o

i don't think this is possible

Sep 17, 2011 at 7:30 PM

Yeah, right now I'm just disabling the body as I create them, but I'd love to be able to create a body and not add it to the world immediatly.

 

As for B, the solution that worked for me is body.Clone() or body.DeepClone().