Open justgook opened 5 years ago
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?
im creating my own.. and that example came from Unity tutorial..
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?
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,
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.
@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.
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. :-)
@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.
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!
@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?
@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. :)
In Chipmunk2D, segments have a "radius", essentially making them capsules.
It would be nice to see capsules implemented for added Godot support!
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](https://user-images.githubusercontent.com/306976/60960097-0af3cf00-a312-11e9-83c2-3639ec9b1320.png)