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.
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.
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.
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.
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;
}
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.