I noticed that the fixture shape dimensions increase properly when the sprite gets taller. Conversely the fixture shape dimensions got stuck to the original sprite dimensions when trying to scale down the sprite.
Many thanks for your hints, help, support. To show this glitch, below is the GML snippets :
In the "Create" event handler :
// which controller
controllerID = 0;
// Configure the fixture
fix = physics_fixture_create();
physics_fixture_set_circle_shape(fix, sprite_width / 2);
physics_fixture_set_density(fix, .01);
physics_fixture_set_restitution(fix, 1.);
physics_fixture_set_friction(fix, 0.5);
//Bind the fixture to the current instance
//my_fix = physics_fixture_bind(fix, object_index);
my_fix = physics_fixture_bind(fix, id);
In the "Begin step" event handler :
var aButton = gamepad_button_check_pressed(controllerID, gp_face1 );
if ( aButton != 0)
{
image_xscale = image_xscale*.9;
image_yscale = image_xscale;
physics_remove_fixture(id, my_fix);
// Configure the fixture
physics_fixture_set_circle_shape(fix, sprite_width / 2);
//Bind the fixture to the current instance
my_fix = physics_fixture_bind(fix, id);
}
var bButton = gamepad_button_check_pressed(controllerID, gp_face2 );
if ( bButton != 0)
{
image_xscale = image_xscale*1.1;
image_yscale = image_xscale;
physics_remove_fixture(id, my_fix);
// Configure the fixture
physics_fixture_set_circle_shape(fix, sprite_width / 2);
//Bind the fixture to the current instance
my_fix = physics_fixture_bind(fix, id);
}
It's easy to check that the fixture shape dimensions does not follow the sprite dimensions when the sprite is contracted : just put physics_world_draw_debug ( phy_debug_render_shapes ) in the "draw event" handler. We can see that the fixture shape dimensions growing with the sprite expansion, but staying constant when the sprite dimensions go back to the sprite original dimensions.
It really looks like a bug in the physcis engine...
Thanks for your comments.
Cheers
Sylvain
finally, I got the answer from both a forum and the YoyoGame editor customer support. Here the link to the forum : https://forum.yoyogames.com/index.php?threads/collision-bounding-box-doesnt-scale-with-image.23941/
Here the answer from the customer services : Thank you for reporting this, but it's not a bug or something we need to address, as you have enabled the Uses Physics option on that object a fixture is created with the settings within that. you should deselect that option as you are using your own fixtures It is not that the fixture created through the UI is primary, rather it is additional. I was able to simply deactivate the Uses Physics checkbox on the object in your project and scaling the object was working correctly. This can be confirmed by drawing the physics debug information in a draw event using, physics_draw_debug(); in a draw event. With Uses Physics ENabled, the outer circle is the UI added fixture:
With Uses Physics DISabled, only one circle conrresponding to the fixture added through the code only :