# How to build a circular wall in Box2D?

This topic is 542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I want to make a circular wall/fence in Box2D so all my sprites will be inside this circular wall and they can collide with each other or collide with the wall. How to make a wall like this in Box2D? Or is it better that if I just implement my own collision detection with the circular wall?

I know how to draw an edge as a fence in Box2D but that fence is always straight and open. If I were to draw a circular wall it would look like a body in Box2D I don't know if other bodies can move and collide inside a body like that.

##### Share on other sites
Last time I did something similar a few years ago, I just constructed the "circle" from lots of boxes, arranged in a circle so that the inner shape was like a many-sided polyhedron.

That was more than accurate enough and combined with a graphical circle, gave the correct impression.

##### Share on other sites

Last time I did something similar a few years ago, I just constructed the "circle" from lots of boxes, arranged in a circle so that the inner shape was like a many-sided polyhedron.

That was more than accurate enough and combined with a graphical circle, gave the correct impression.

Thanks that sounds like a good idea. How does the performance go? I mean when we need to do collision detection with that chained boxes, there would be a lot more calculation than simple geometric calculation like checking if the sprites go beyond the radius.

##### Share on other sites

Hi, my box2d is also very rusty, but you shouldn't need boxes if you only need the collisions to be against an edge.
The question here is if the boxes (Non-AABB) will perform better than the polygon shapes.

There's this website I used a lot, years ago, when learning box2d: http://www.iforce2d.net/b2dtut/fixtures
I sent the link about fixtures, there you can read about PolygonShape; that's why I'd try first. Make sure to check the limit of vertices on the polygon shape.

Also, about the circle, the idea sounds great, but I never saw anything like an empty circle shape on box2d, so I don't think you can get away with something that simple (even you should be able to, in theory).

Cheers

##### Share on other sites

Last time I did something similar a few years ago, I just constructed the "circle" from lots of boxes, arranged in a circle so that the inner shape was like a many-sided polyhedron.

That was more than accurate enough and combined with a graphical circle, gave the correct impression.

Thanks that sounds like a good idea. How does the performance go? I mean when we need to do collision detection with that chained boxes, there would be a lot more calculation than simple geometric calculation like checking if the sprites go beyond the radius.

The game I was working on created huge levels with hundreds of Box2D shapes and I never had any performance issues. This was years ago on far less powerful machines than we have today.

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009197
• ### Who's Online (See full list)

There are no registered users currently online

×