GameMaker Resizing Fixtures - Both stick, can't seem to remove the first.

D

Dan B

Guest
Okay, so this is my first post in the GM:S forums. I've learned SO much from previous questions from users. I've just started learning about 3 months ago and w/ enough persistence I've always found an answer.

Unfortunately, this one has stumped me and so has 50 'googles'; so without further or due:

I have 'physics' off, and am using this code in my 'create':

Code:
col_move = physics_fixture_create();
physics_fixture_set_box_shape(col_move, sprite_get_width(sprite_index) / 2, (sprite_get_height(sprite_index) / 2));
physics_fixture_set_density(col_move, 0.5);
physics_fixture_set_restitution(col_move, 0.1);
physics_fixture_set_linear_damping(col_move, 0.1);
physics_fixture_set_angular_damping(col_move, 0.1);
physics_fixture_set_friction(col_move, 0.2);
physics_fixture_set_awake(col_move, true);

physics_fixture_bind(col_move, obj_player);

physics_fixture_delete(col_move);
This does create my standard collider, after that, in my "scr_move_state", I have a skill trigger (via double tapping) that changes to the "scr_dash_state".

Just before I change states, I use "physics_remove_fixture(obj_player, col_move)"

Then, I trigger the 'scr_dash_state', within this state, I simply multiply my speed, and use this block:

Code:
col_dash = physics_fixture_create();
physics_fixture_set_box_shape(col_dash, sprite_get_width(sprite_index) / 2, (sprite_get_height(sprite_index) / 2));
physics_fixture_set_density(col_dash, 0.5);
physics_fixture_set_restitution(col_dash, 0.1);
physics_fixture_set_linear_damping(col_dash, 0.1);
physics_fixture_set_angular_damping(col_dash, 0.1);
physics_fixture_set_friction(col_dash, 0.2);
physics_fixture_set_awake(col_dash, true);

physics_fixture_bind(col_dash, obj_player);

physics_fixture_delete(col_dash);
(Picture of examples, below)

While in my 'scr_move_state' my player is the shape of example '1', appropriately. When I'm in 'scr_dash_state' my player is SUPPOSED to be in the shape of example '2'. When I'm in the 'scr_dash_state' the 'scr_move_state' fixture still exists creating the fixture shape with the two combined; so I'm (physically) shaped like example '3' (note: my sprites work flawlessly, this is just a fixture issue)

I haven't gotten as far as removing the 'scr_dash_state' fixture because I can't even remove the 'scr_move_state' fixture during the 'dash'. This is surely incomplete~

Can someone please point me in the right direction? I guess I'm having 'conceptual' issues w/ using multiple fixtures. Ugh...
 

Attachments

I think I found your problem straight away, but appologies if I'm wrong (disclaimer: I didn't read your whole text). Double disclaimer: I'm assuming this works the same way with GMS2 as it does with GMS1.

So, what you want to do is remove the fixture bound to the instance, the one that was returned by the function physics_fixture_bind. What you are presently doing is trying to remove the fixture prototype "col_move", which a) is not bound to the instance, and b) you've already deleted anyway.

see below:

col_move = physics_fixture_create();
...
my_fix = physics_fixture_bind(col_move, obj_player);
physics_fixture_delete(col_move);
physics_remove_fixture( id, my_fix );
 
Top