HTML5 Fixture Incorrectly Bound in HTML5 Export

Mookal

Member
I'm making a game where walls can be drawn by the player. To cut down on the amount of instances, some walls are made longer when the player moves the mouse across the screen quickly. Because of this, I need to create a properly scaled fixture for each wall object.
The issue is that, while the fixtures are properly sized in the Windows export, the fixtures in the HTML5 export are all very large squares.

help2.jpg
help.jpg
Left is Windows, right is HTML5. The collision boxes are visualized in red using physics_draw_debug().

Here is the code for creating the walls.
GML:
///@function make_wall_line();
///@param x1
///@param y1
///@param x2
///@param y2
///@param type (which wall object to create)

var point_x1 = argument0;
var point_y1 = argument1;
var point_x2 = argument2;
var point_y2 = argument3;
var obj = argument4;

var dist = point_distance(point_x1, point_y1, point_x2, point_y2);
var dir = point_direction(point_x1, point_y1, point_x2, point_y2);

//Create the Wall object
var inst = instance_create_depth(point_x1, point_y1, 0, obj);
with inst{
    //Scale the wall according to the distance between the two points
    image_xscale = max(dist/7, 1);
    
    //Create and bind the fixture
    fixt = physics_fixture_create();
    
    //The wall sprite's origin is middle left
    var corner_x1 = 0;
    var corner_y1 = -3;
    var corner_x2 = sprite_width;
    var corner_y2 = 3;
    
    //Using polygon instead of box because it wouldn't center properly, even with physics_fixture_bind_ext
    physics_fixture_set_polygon_shape(fixt);
    physics_fixture_add_point(fixt, corner_x1, corner_y1);
    physics_fixture_add_point(fixt, corner_x2, corner_y1);
    physics_fixture_add_point(fixt, corner_x2, corner_y2);
    physics_fixture_add_point(fixt, corner_x1, corner_y2);
    
    //Using physics_fixture_bind_ext because physics_fixture_bind is broken in HTML5
    physics_fixture_bind_ext(fixt, id, 0, 0);
    
    //Set the object's rotation now that the fixture is assigned
    phy_rotation = -dir;
}
I've tried a couple different things, such as having the HTML5 export use a box fixture or not adding any points at all, but the fixtures always get set as the large squares.
Does anyone know what's going on here? I've had a lot of issues in the past with HTML5 and the physics system, so this may very well be another case of GMS2 just not working properly.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Sounds like a bug to me, I'm sorry to say. :(

Please file a report and attach a link to the project. The next updated (2.3.0) has a few fixers for HTML5, but I don't know if this is one of them, so best to file the bug report to be sure...
 

Mookal

Member
Sounds like a bug to me, I'm sorry to say. :(

Please file a report and attach a link to the project. The next updated (2.3.0) has a few fixers for HTML5, but I don't know if this is one of them, so best to file the bug report to be sure...
Thanks, I'll be sure to file a report.
Meanwhile, it seems I've found a solution, though it's a bit of a hacky one. Kind of a given when working with fixtures and HTML5, I've come to find. A lot of the particulars are specific to my game, but one big thing I've found is that you can use physics_fixture_set_box_shape() in HTML5 instead of physics_fixture_set_polygon_shape(), and it works fine. It's weird, considering box_shape doesn't seem to work for Windows (at least the last time I tried it), and it didn't work when I tried it with HTML5 earlier.
Regardless, I've found a workaround. I'll get on that bug report now.
 
Top