can I change the fixture definition of a fixture after attached to a body? for example,making the player become smaller after colliding with some thing
Box2d API allows this. (you can get the shape from fixture and then modify it). But we haven't wrap this functionality yet. Optionally, you can destroy fixture and then create new fixture again. I'm adding this to the requests list. With the next version, we'll implement getting shapes from fixtures.
Edit: I think, if you store your shape, you can modify it later. For example:
local shape = b2.CircleShape.new(0, 0, 30)-- it's radius is 30local fixture = body:createFixture({shape = shape, density =1})
fixture.shape = shape --> we store the shape here-- later.....
fixture.shape:set(0, 0, 20)-- make radius 20
Edit 2: Also, there is a warning at box2d's reference manual: You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.
Comments
Edit: I think, if you store your shape, you can modify it later. For example:
Edit 2: Also, there is a warning at box2d's reference manual: You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.