How to use for a 2D game?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
rockseller
Posts: 1
Joined: Tue Oct 16, 2018 4:14 am

How to use for a 2D game?

Post by rockseller » Tue Oct 16, 2018 4:17 am

I want to use BEPUphysics for a 2D game,
What must I set on the code to make this possible?

Thanks

Norbo
Site Admin
Posts: 4558
Joined: Tue Jul 04, 2006 4:45 am

Re: How to use for a 2D game?

Post by Norbo » Wed Oct 17, 2018 12:03 am

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 solver-aware 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.

PhilipArthurMoore
Posts: 11
Joined: Sat Oct 13, 2018 1:40 am

Re: How to use for a 2D game?

Post by PhilipArthurMoore » Fri Oct 19, 2018 10:32 am

i suggest you should use a 2d engine physics

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest