Is there a possibility of storing Box2D/Farseer Body object without World object?

StackOverflow https://stackoverflow.com/questions/22943724

  •  29-06-2023
  •  | 
  •  

Вопрос

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?

Это было полезно?

Решение

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?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top