Wall Fixtures not creating as expected.

R

Rizlad

Guest
I'm creating some scripts to create a fixture for a wall segment, (in this example a bottom),
using the bottom left corner here and spanning right checking for end of the wall segment to then create the appropriate fixture.
The fixtures aren't quite the right lengths and are not in the right spots, any insight into that problem or any other thoughts on this bit of code would be appreciated!


Code-

///scr_get_fixtures_b
//fdis starts @ 32;

inst = instance_place(x+fdis,y,obj_cwall);//check for wall end
if inst = noone {
fix = physics_fixture_create();
physics_fixture_set_polygon_shape(fix);
physics_fixture_add_point(fix, 0,0);
physics_fixture_add_point(fix, fdis, 0);
physics_fixture_add_point(fix, fdis, 32);
physics_fixture_add_point(fix, 0, 32);
physics_fixture_bind_ext(fix,self,fdis / 2, -(32 / 2));
physics_set_density(fix, 0);
physics_fixture_delete(fix);

}else{
fdis += 32;
scr_get_fixtures_b();
}
 
Last edited by a moderator:
J

jaydee

Guest
The Physics system doesn’t use pixels for measurement, it uses metres. You also have to set a pixel to metres ratio in the room editor.

So you then use:
pixels = metres / ratio
Or
Metres = pixels * ratio

To work out your lengths.
 
R

Rizlad

Guest
checked pixel ratio in room they are were already set,
but not sure what you meant by the second bit there
 
J

jaydee

Guest
My guess is that you’re intending to use a block 32 pixels long, not 32 metres long? If so, you’d need to use:

32 * ratio (let’s assume 0.05) = 1.6

Therefore you’d replace the value of 32 with 1.6 when you’re creating the fixture.
 
Top