Creating Physics Fixtures in code and "flipping" them

Hi all, I created some fixtures in code to use and I'm wondering if it's possible to to just "flip" or mirror them so that it's the same fixture, but mirrored, depending on which direction the sprite is.
I've seen a couple threads about this already, but they didn't really go into detail on why something did or did not work.
The only solution I found so far is to manually flip the sprite in the sprite editor and count out the different points I need and create a whole new fixture.
Anybody have any advice or help? Thanks!
 
If you are creating your fixture shape using the "Modify Collision Shape" option in the object panel then you should be aware that you CAN NOT retrieve the data from this source, and use it/edit it. Soo flipping/mirror is off the table.

If you are instead creating your fixture using functions like the following. Then there are no worries.

physics_fixture_set_polygon_shape(fix_Ship);
physics_fixture_add_point(fix_Ship, 0,0);
physics_fixture_add_point(fix_Ship, -40, 100);
physics_fixture_add_point(fix_Ship, 40, 100);

If you are using the first option I described I would then recommend switching to the second, and only use the "Modify Collision Shape" panel as a REFERENCE to get the x,y coords that you need.

In order to execute the flipping function, you are looking for for the second option its merely a matter of setting up some kind of array or data structure and then mirroring all the points in the data structure and creating a new fixture with the new mirrored points (you may also have to rearrange the points from counter-clockwise to clockwise or visa-versa but I'm not sure) I'm not going to go into detail about this because I'm not sure if this is something you want to do.
 

Bart

WiseBart
The only solution I found so far is to manually flip the sprite in the sprite editor and count out the different points I need and create a whole new fixture.
That's basically how you have to do it, unfortunately.

There is no way to scale or mirror a bound fixture. Which is logical, in a way, if you look at it from a physics perspective.

As mentioned already the fixture that you define in "Modify Collision Shape" cannot be accessed since GM doesn't have a function to retrieve it.
You can only access and modify bound fixtures that you define in code yourself and then bind using physics_fixture_bind.

I think the easiest solution to your question is to create two fixtures using physics_fixture_create, one of them with "normal" coordinates and the other with the mirrored coordinates. And have one of the two bound to the instance depending on the direction it's facing.
Or, alternatively, you can define just one fixture and keep the points somewhere in an array or a list.
Then, before binding the new fixture, modify its shape and bind it.

Hope this can help a bit :)
 
Top