Awesome that you are using the Def-Diags library, makes me happy! I’ll look into the Linux support as soon as we have support for it in native extensions. I know the library I use has Linux support, so hopefully it shouldn’t be too hard.
@Oleg_The_Evangelist Haha. Hey, it’s only 7:30 AM here! It’ll get there.
@sven Having native dialogs makes me pretty happy too! It’s so awesome. Yeah, I saw that the library has Linux support, which is great. I decided to go ahead with it, figuring it would only be temporary breakage. Thanks for making the native extension!
Oof, how the heck has it been 25 days?!
You’re a god. Game ideas are pouring out my brain because of this. Thank you XD. Ill probably use this sometime in the future after getting comfortable with using Defold.
@ross.grams hey! thanks for your editor!
any idea how to add the polygon figure with internal angles? like this? split into 3 figures?
Yeah, that would have to be split up. All shapes must be convex like a ball “( )”. Any concave shapes, like the inside of a bowl " ) ( ", doesn’t work for collision.
Yep, what Mattias said. But if you want to create a dynamic collision object with that shape, as far as I know it is not possible. Polygons are treated differently from other collision shapes, and you can only use one per collision object. If you want a static, kinematic, or trigger body this shouldn’t be a big problem (you just add multiple collision object components), but with dynamic bodies each component will be a separate object, so you can’t have multiple polygons “welded” together. You can use one polygon and multiple “normal” collision shapes though.
Finally used this in a project. I may have a pull request in the future with some new features…
I highly recommend people use this tool if they need shapes which they are tempted to make from combining multiple premade collision shapes together. Previously on a project I was using a box and a circle to make a pill like shape, and had some bugs for a while I didn’t know the cause. Turns out it was the box shape’s corners causing the bugs. Instead making a water tight custom shape with this tool fixed the issues.
Would this shape ever be possible, even if breaking it up into multiple collision shapes?
In Box2D a chain shape would work, because those don’t have the limitations of bodies made up of polygon shapes. Are chain shapes supported by Defold? I’m guessing not.
Maybe a Tile Map could be used instead?
You can make any shape you want if you break it up into pieces. This tool is really, really simple and doesn’t do that for you though. Depending on how precise you want it, you could probably do this with 4 shapes. Though if you want to use it for a dynamic body, as far as I know Defold doesn’t let you have multiple polygons on a single Collision Object, so you can’t really make dynamic bodies with multiple polygons.
Tile Maps only do convex collision as well, though if you split this up over multiple tiles, that -might- be easier than using polygons. I’m not sure how well that would work, but it’s worth a try.
For this project it looks like Tile Map is out:
The result is a bit too uneven and unpredictable. Maybe a different approach entirely is the way to go, by somehow calculating the y collision of the character. The mechanic is similar to Tiny Wings and those types of games.
Ah, yeah. For that kind of game I think a more mathematical approach would be better. Use a Bezier curve and do the math for a body on an inclined plane yourself.
[Edit] Actually, the physics part would only be a few lines of code. The trickier parts would be:
- Find a good Bezier curve Lua library and figure out how to use it, (or write one yourself…).
- Get the slope of the curve at the X-position of your character.
- Figure out how to draw the ground to match the curve. (put the Bezier math into a shader and stretch/skew a texture to fit?)
Would be cool if the editor could automatically divide and generate sets of ready to use collision shapes for concave bodies maybe even with a go with all of the shapes defined too. Anyone out there could add support for this…
Doesn’t have to be automatic, could add cut ability between points and then mark the remaining concave subshapes.
Alternatively, load a JSON file spat out by RUBE! It divides shapes into separate convex fixtures automatically.
Can’t RUBE export custom formats?
Yeah, this solution sounds like a can of worms (to me). I was hoping to be able to stick to standard Defold objects, so I can visualise it in the amazing IDE. Trying the “many collisions shapes” idea now, praying it will be good enough.
It can export to JSON or C code.
Ok lovely people, I’ve created a VERY rudimentary bridge between RUBE and Defold. Maybe this could be useful for reference when integrating a more robust polygon support in Defold, or maybe even offer RUBE support.
First, a video of the result:
This uses collision data from a RUBE JSON file:
test.json.zip (1.3 KB)
I wrote a small Lua script to extract the data and print it in the right format:
local data = sys.load_resource("/json/test.json")
local data_table = json.decode(data)
local bodies = data_table.body
for b=1, #bodies do
local body = bodies[b]
local fixtures = body.fixture
for f=1, #fixtures do
print( "shape_type: TYPE_HULL" )
local fixture = fixtures[f]
local polygon = fixture.polygon
local vertices = polygon.vertices
local xs = vertices.x
local ys = vertices.y
for v=1, #xs do
local x = xs[v]
local y = ys[v]
print( "data: ", x )
print( "data: ", y )
print( "data: 0.0" )
end
print()
end
end
Then I added the 15 (!) collision shapes to the game object, each file containing a convex polygon, making up the final concave polygon:
Now I need a coffee.
The test project zipped: PolygonTest.zip (75.6 KB)
Well-deserved, amazing work