I need to read data of a Body
, but I don't have World
object yet. This Body
is needed only to store informations about it. Do I have to have a dedicated World
object for that?
Asked
Active
Viewed 131 times
1 Answers
1
I believe the answer is Yes, you need to a Box2D World to add Box2D bodies to..
Without a World, the body has nothing to be a part of. You can have multiple Worlds and each of them has their own bodies associated with it, which are completely separate.
It sounds like you may be trying to solve a different problem...maybe the "Entity" vs. "The body that the Entity is representing." That is to say, a game entity (ball, car, "thing", etc.) is represented by a class that creates a body when it needs to be represented in the physics world.
When the body is created, set its userdata to reference the entity that owns it.
Is this where you are going?

FuzzyBunnySlippers
- 3,387
- 2
- 18
- 28
-
I create an editor of an open world game, and I cannot have the whole world loaded. I need to store newly created/edited bodies in a form that doesn't interfere with my main world, and reload the body if it is needed again. I just have an additional world for that right now, and it is OK. – Michał Apr 09 '14 at 12:26