Wow, that was news to me. enlighted…
Could you check this again / upload a sample?
I tried to get it work work but got this error
Could not open the editor: collisionobject node could not be loaded: Not implemented: TYPE_HULL
I created a test.convexshape file, edited it as text at first but we seem to have a very basic editor for it as well:
Then I created my go-file, added a collisionobject component and set the “Collision Shape” to the test.convexshape file:
(I don’t think we render it correctly in the collection editor though, but it should show up in the engine.)
Hello @sven
I am trying to port my game to defold. Need some collider power! Endup with this topic.
I couldnt make it work.
It shows the points on editor, but crashes on build. Also gives a warning on editor;
`Assertion failed: 3 <= count && count <= 16, file …\src\box2d\Box2D\Collision\Shapes\b2PolygonShape.cpp, line 122
Than i reduce to points to 5 (5*3=15)
Assertion failed: area > 1.192092896e-07F, file …\src\box2d\Box2D\Collision\Shapes\b2PolygonShape.cpp, line 115
Is there any other way to add collider from image alpha. Or its only the primitive colliders for now.
Best Regards,
If you use tilesources you can get shapes from alpha. Check out http://www.defold.com/manuals/physics/#anchor-tcs
Note too that the polygon you specify has to be convex. I’m not sure but the area message might indicate that your shape is not.
Hello @sicher
I used that method. But i didn’t satisfied with the result. Maybe it works with little tiles, didn’t try it.
I think i will stick with default colliders for now.
Best Regards,
Since you have “valleys” in the ground shape you can’t get a convex shape to fit well. You will have to split it in pieces (tiles) that are convex, or work with multiple simple shapes as you currently do.
is it still possible to create convexshape file in editor 2?
thank you
hm, an error happens while using generated file
Assertion failed: (3 <= count && count <= 16), function Set, file …/src/box2d/Box2D/Collision/Shapes/b2PolygonShape.cpp, line 122.
image file is the same as was used for shape…
Ooh, sorry about that. I fiddled around a bit and it looks like Box2D won’t take a polygon with more than 16 vertices. If you simplify your shape it should work, let me know if it doesn’t.
thank you for reply the same that I thought by the error but was not sure
I’m currently looking for a solution for this.
I want to have a hex-shaped collision. Right now I’m thinking of writing my own .convexshape file or using tile collisions. I’m not sure which one is the better option.
The tile collision option would be to use multiple small tiles, around 16x16. The collisions would not involve physics. They’re mainly for triggers.
Thanks. I’ve tried 2, but it wasn’t working. I think it’s been depreciated.
I’m currently looking into tile-based collisions. I think I could create the shape I want, a hex, using tiles.
There’s various requests on github for custom collision shapes in the editor. Upvoting them might help
It may. I’m working on my own solution first.