The Wayback Machine - https://web.archive.org/web/20211227074444/https://github.com/mapeditor/tiled/issues/2153
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision capsule #2153

Open
justgook opened this issue Jul 10, 2019 · 12 comments
Open

Collision capsule #2153

justgook opened this issue Jul 10, 2019 · 12 comments

Comments

@justgook
Copy link

@justgook justgook commented Jul 10, 2019

For physics engine much easier is deal with capsules instead of ellipse, now on tiled side i use ellipse to determinate capsule colliders, would be nice to have ability, to switch between ellipse / capsule representation of circles when width and height are not equals, or maybe just add new shape ?
CapsuleCollider2D-Example2

@bjorn
Copy link
Member

@bjorn bjorn commented Jul 10, 2019

Hmm, that'd definitely be an interesting new shape to add. Looks like it would not be a big change to support it. Which physics engine are you using?

@justgook
Copy link
Author

@justgook justgook commented Jul 10, 2019

im creating my own.. and that example came from Unity tutorial..

@bjorn
Copy link
Member

@bjorn bjorn commented Jul 10, 2019

So I guess this shape is not commonly supported by collision engines, but it could still be generally useful since it can be easily converted to two circles and a rectangle or a polygon if needed.

Would you like to have a go at adding this?

@justgook
Copy link
Author

@justgook justgook commented Jul 10, 2019

im not really good in C++ stuff.. so not really have clue how / where to add / make PR.. but that is kind of base shape for most of game engines, to represent characters.. and that also have lot of examples in 3d,

@SSBMTonberry
Copy link

@SSBMTonberry SSBMTonberry commented Jul 12, 2019

For physics engines used in games, this is a actually a very common shape, and would be great to have in Tiled! It's commonly used for player objects or any other objects that does not fit a square shape. Square shapes and collisions tend to be a bit tricky to handle smoothly using physics engines, which is why circles and capsules are commonly used for moving objects.

@bjorn
Copy link
Member

@bjorn bjorn commented Jul 12, 2019

@SSBMTonberry Right, but at the same time I don't know about any (2D) physics engine that specifically supports capsules. Chipmunk2D has circles, lines and polygons. Box2D (and hence planck.js) do convex polygons and circles (lines as well), Matter.js supports polygons and circles. I haven't yet found a library that does capsules.

So, it appears to me that a capsule will generally need to be modeled with either a polygon or combination of a box and two circles. And in that case I don't see a big advantage of having a capsule directly supported in Tiled. But in any case I'm certainly not opposed to adding it.

Maybe I can help you getting started with the C++ part, @justgook. There's a wiki page about Contributing to Tiled that's meant to guide you through setting up your development environment.

@bjorn
Copy link
Member

@bjorn bjorn commented Jul 12, 2019

Erm, alright, you mentioned a Unity tutorial, but in fact your example comes from the Unity 2D physics engine, which apparently does support capsules. So we've found a pretty significant one. :-)

@SSBMTonberry
Copy link

@SSBMTonberry SSBMTonberry commented Jul 12, 2019

@bjorn : Capsules are usually made by combining a box and two circles, like you say. I'm using a collision detection library called cute_c2, which is a single header library. It supports capsules directly. For both Box2D and Chipmunk I think the most common way of producing capsules is by combining two circles and a box, which a capsule is made of anyways.

@Seanba
Copy link
Contributor

@Seanba Seanba commented Jul 12, 2019

Small request if this is added to Tiled: Please point me to the parametric equation used to approximate the shape of these capsules. I will add that to SuperTiled2Unity. Thanks!

@bjorn
Copy link
Member

@bjorn bjorn commented Jul 12, 2019

@Seanba Hmm, what do you need that for? I'm not sure what such an equation would look like. Why not use two circles and a box to model the exact shape?

@Seanba
Copy link
Contributor

@Seanba Seanba commented Jul 12, 2019

@bjorn Under some conditions I have to approximate all shape types as polygons. I figured I would piggy back on whatever you use for displaying the outline of a capsule shape but I've got other ways to get what I need through the Clipper library if need be. :)

@TheRealOrangus
Copy link

@TheRealOrangus TheRealOrangus commented Jul 23, 2019

In Chipmunk2D, segments have a "radius", essentially making them capsules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment