I want to use BEPUphysics for a 2D game,
What must I set on the code to make this possible?
Thanks
How to use for a 2D game?
Re: How to use for a 2D game?
There is no '2d mode', so you have to somehow control objects so that they sit on a 2d plane and only rotate around one axis.
The easiest approach is setting two of the rows of the local inverse inertia tensor in every dynamic body to all zeroes. That gives the body effectively infinite inertia around both axes, leaving only one remaining axis of rotation.
Handling position is a little trickier. The easiest approach would be to correct any velocity or position drift along the 2d plane normal by setting the Position and LinearVelocity appropriately. A slightly more robust approach would be to use a solveraware constraint like the LinearAxisMotor to control the position, but that's not computationally free.
Also, since it is a fundamentally 3d engine, if two objects get shoved into one another and the shortest separation is along the 2d plane normal, collision detection will waste time trying to separate the objects along that normal rather than along the surface of the plane. This can result in objects getting stuck in some cases and there's no super elegant way to deal with it (other than to not let it happen to begin with).
Unless you have some specific need for 3d, using a dedicated 2d engine could be easier.
The easiest approach is setting two of the rows of the local inverse inertia tensor in every dynamic body to all zeroes. That gives the body effectively infinite inertia around both axes, leaving only one remaining axis of rotation.
Handling position is a little trickier. The easiest approach would be to correct any velocity or position drift along the 2d plane normal by setting the Position and LinearVelocity appropriately. A slightly more robust approach would be to use a solveraware constraint like the LinearAxisMotor to control the position, but that's not computationally free.
Also, since it is a fundamentally 3d engine, if two objects get shoved into one another and the shortest separation is along the 2d plane normal, collision detection will waste time trying to separate the objects along that normal rather than along the surface of the plane. This can result in objects getting stuck in some cases and there's no super elegant way to deal with it (other than to not let it happen to begin with).
Unless you have some specific need for 3d, using a dedicated 2d engine could be easier.

 Posts: 12
 Joined: Sat Oct 13, 2018 1:40 am
Re: How to use for a 2D game?
i suggest you should use a 2d engine physics