Original Post
Hi,
I'm using Box2d.
In my game I have buildings that you can enter and when you are inside I want you not to be able to walk outside of the edges of the building. When I say building I basically mean rectangle.
At first I was wondering if there was a way to set a box2d body to stop other bodies leaving it instead of separating them (basically the opposite) but I don't think you can do this.
Then I thought I would make 3 separate bodies each with a different shape which would be the 2 walls and the ceiling and then I would connect them with a couple of joints. This method seems a bit overkill in my mind.
What I would like ideally is 1 body with 3 shapes attached to it so the centre of the body is still the centre of the building but I can't think of a way to do this as I'm not too sure how I would position the shapes.
Have I missed something really obvious?
Does anyone know a good way of doing this?
Thanks for your help.
I'm using Box2d.
In my game I have buildings that you can enter and when you are inside I want you not to be able to walk outside of the edges of the building. When I say building I basically mean rectangle.
At first I was wondering if there was a way to set a box2d body to stop other bodies leaving it instead of separating them (basically the opposite) but I don't think you can do this.
Then I thought I would make 3 separate bodies each with a different shape which would be the 2 walls and the ceiling and then I would connect them with a couple of joints. This method seems a bit overkill in my mind.
What I would like ideally is 1 body with 3 shapes attached to it so the centre of the body is still the centre of the building but I can't think of a way to do this as I'm not too sure how I would position the shapes.
Have I missed something really obvious?
Does anyone know a good way of doing this?
Thanks for your help.