I’m trying to set the dimensions of a box shape at runtime:
local shape =
{
type = physics.SHAPE_TYPE_BOX,
dimensions = self.dimensions
}
physics.set_shape(msg.url(nil, nil, "collider"), "shape", shape)
This documentation shows that I need a type field in the table, however Defold doesn’t recognize any physics.SHAPE_... options. (I’m using the latest version of the editor.)
This documentation strangely doesn’t include the type field. If I remove it from the table, I get the following error:
bad argument #6 to 'set_shape' (number expected, got nil)
…which is weird because there are a maximum of three arguments, not six. The url to the collision object (collider) is correct, and the name of the shape itself (shape) is correct. Here is a snippet of the hierarchy:
It’s not enough info. Please provide a minimal repro case (a small, isolated project where the issue you are talking about is reproducible). Maybe you’ll find what did you miss.
Because here is my example I’ve just made and it works fine:
The shape types are set as “constants” here in script layer of the physics code:
This means that if you iterate _G.physics at runtime you should see them together with all the other functions and constants.
But that is not enough for the editor to know about them, or for the API reference to include them. The code must also have code annotations that we can pick up and use when we generate the API docs and auto-complete for the editor, like these ones for the joint types:
Would you like to attempt a PR to add the shape type constants?
I’m not really into the source code thing. There are much better devs for that stuff. But I’m talking about the documentation to make it easier to use defold’s features & APIs. They are accurate, but very technical and some written where it’s clear it was from someone that understands the source code.
It would be cool, if there was a concentrated effort (aka make it easy) for us to update the manual on how to use the features/APIs. Once again what is there isn’t “wrong”, but it’s very high level and technical. A more practical how-to on many of the features would be great. Leveraging the user community would really help.