does defold support only three shapes for collision?
Actually five. You can create your own convex hull shape with a
.convexshape file, something like;
shape_type: TYPE_HULL data: -10 data: -10 data: 0 data: 10 data: -10 data: 0 data: 0 data: 10 data: 0
This should create a triangle shape (I think, haven’t tested it).
Oh, nice, I didn’t know about that!
thank you!!!(because we need at least 20 characters to reply)
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.)
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.
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.
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.
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?
Try using this https://github.com/rgrams/defold_polygon_editor
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.