*** SOLVED *** Physics fixture does not exist, but it should...?

toxigames

Member
*** SOLVED ***

EDIT: Nevermind this has been solved; I had another variable fixture that I was setting to -1 in a texture terrain script that I had overlooked was being called (called from wrong place, must've pasted it by error some time).

----

I have the following parent/child hierarchy to create physics objects. I don't understand why I get the error mentioned below at line 21/22 about "physics fixture does not exist". According to the parent/child hierarchy the fixture = physics_fixture_create(); should be run before physics_fixture_set_chain_shape(fixture, false); So the fixture should exist... so why doesn't it? I am only deleting it later.(I tried searching for physics_fixture_delete(fixture); in all scripts but it is only found 1 time, at the end of create event of grounds_par_obj at line 44 and that is after the error happens).

I suspect that this is just one those stupidly simple bugs that I am simply failing to see, so I hope there is someone who can enlighten me! thanks!

Code:
1
2 // *** statics_par_obj ***
3 // has no parent
4 // CREATE EVENT
5 fixture = physics_fixture_create();
6
7
8 // *** groundsAll_par_obj ***
9 // parent is statics_par_obj
10 // CREATE EVENT
11 // event_inherited();
12 // I could have omitted this create event for now, but
13 // the reason its here already is I later plan to add some
14 // variables to  it that must be inherited to all children.
15
16
17 // *** grounds_par_obj ***
18 // parent is groundsAll_par_obj
19 // CREATE EVENT
20 event_inherited();
21 physics_fixture_set_chain_shape(fixture, false);
22 // <-- causes error that the physics fixture does not exist.
23 // But why? fixture = physics_fixture_create(); should already
24 // have been run through event_inherited(); at line 20?
25 var gridLen = ds_grid_height(pointsGrid);
26 physics_fixture_add_point(fixture, -10, firstPolyY+3);
27 // the extra -10 and +3 is to avoid hard corners on first
28 // poly so that player does not "bump" over them
29 for(f = 0; f < gridLen; f++){
30     if(f == 0){
31         //physics_fixture_add_point(mainFixture, x-10, y+firstPolyY+10);
32     }
33     chainShapePointX = ds_grid_get(pointsGrid,0,f);
34     chainShapePointY = ds_grid_get(pointsGrid,1,f);
35     physics_fixture_add_point(fixture, chainShapePointX-x, chainShapePointY-y);
36     if(f == gridLen-1){
37        physics_fixture_add_point(fixture, sprite_width+10, lastPolyY+3);
38        // the extra +10 and +3 is to avoid
39        // hard corners on last poly so that
40        // player does not "bump" over them
41     }   
42 }
43 physics_fixture_bind(fixture,id);
44 physics_fixture_delete(fixture);
45
46
47 // *** groundGrass_001_512x108_01_obj ***
48 // parent is grounds_par_obj
49 // CREATE EVENT
50 firstPolyY = 34;
51 lastPolyY = 34;
52 y = controller_obj.previousIns.y - (firstPolyY - controller_obj.previousIns.lastPolyY);
53 //Node count: 7;
54 pointsGrid = ds_grid_create(2, 7);
55 ds_grid_set(pointsGrid, 0, 0, 0+x); ds_grid_set(pointsGrid, 1, 0, 34+y);
56 ds_grid_set(pointsGrid, 0, 1, 40+x); ds_grid_set(pointsGrid, 1, 1, 31+y);
57 ds_grid_set(pointsGrid, 0, 2, 79+x); ds_grid_set(pointsGrid, 1, 2, 9+y);
58 ds_grid_set(pointsGrid, 0, 3, 226+x); ds_grid_set(pointsGrid, 1, 3, 1+y);
59 ds_grid_set(pointsGrid, 0, 4, 302+x); ds_grid_set(pointsGrid, 1, 4, 29+y);
60 ds_grid_set(pointsGrid, 0, 5, 453+x); ds_grid_set(pointsGrid, 1, 5, 42+y);
61 ds_grid_set(pointsGrid, 0, 6, 511+x); ds_grid_set(pointsGrid, 1, 6, 34+y);
62 event_inherited();
63
 
Last edited:
Top