GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-06-04 23:37:34

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

collision_* - ignores image_angle if sprite/mask not transparent

Brief Description:           Most collision functions ignore image_angle if sprite/mask not transparent
GM Versions:                  GM6, GM7
References:                    <none>
Example File:                  http://www.planetxot.com/download/colli … le_bug.gm6
Bug Confirmed:               ---
Hardware Dependent:    No

Main Info:

Forum member Marchal_Mig12 noticed a problem with the normal_detect script posted on the main site. This lead to the discovery of a Game Maker bug.

It appears that if the sprite or collision mask are not transparent, the collision_* functions will not take image_angle into account. The function instance_position also has the same problem. Transparent sprites/masks work as expected. This affects GM6 and GM7. The other sprite transforms, image_xscale and image_yscale, work as expected.  If the sprite/mask is transparent, all collision functions work as expected. In addition, the place_meeting, place_free, place_empty, and instance_place functions always work as expected.

GM5 doesn't have an image_angle sprite transform, so it appears to be working correctly. I did not do very much testing in GM5, but everything worked as expected in the tests I tried (collision_point vs. place_meeting).

I'm surprised I haven't seen this reported before.


Demonstration:

This tests various collision functions against transparent and non-transparent sprites with various sprite transforms. F1 for help.

http://www.planetxot.com/download/colli … le_bug.gm6

I may have forgotten some tests. I also did not test any collision or boundary events.


Workarounds:

None yet known that are very nice. One possibility is to increase the vertical size of the problem sprites by one pixel, setting the problem sprites to be transparent, in ensuring that the transparency only affects the bottom row of pixels.


Abusing forum power since 1986.

Offline

#2 2009-06-05 18:49:46

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: collision_* - ignores image_angle if sprite/mask not transparent

After sleeping on this I am beginning to think that what may be going on here is that Game Maker is overriding precise collisions if transparency is not selected. Perhaps this is just a poorly thought-out optimization, an optimization that was never applied to place_meeting, place_free, place_empty, and instance_place.


Abusing forum power since 1986.

Offline

#3 2009-06-06 12:25:57

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: collision_* - ignores image_angle if sprite/mask not transparent

That means that in case we did not select precise collision checking, image_angle will be ignored by collision_* functions even though it is transparent?

Offline

#4 2009-06-06 21:36:32

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: collision_* - ignores image_angle if sprite/mask not transparent

Yes, that's true for all of the collision_* functions, as well as instance_position. When "Precise collision checking" is not enabled, collisions with both transparent and non-transparent objects behave the same. The other collision checks (place_meeting, place_free, place_empty, and instance_place) seem to always do a precise check. I don't know if that's a bug, or simply undefined behavior.


Abusing forum power since 1986.

Offline

#5 2009-06-13 14:02:27

flexaplex
Member
Registered: 2008-12-11
Posts: 72

Re: collision_* - ignores image_angle if sprite/mask not transparent

Well I can confirm this bug in GM7. I think you are probably right with your guess that precise collision checking is turned off for non-transparent objects. Likely though that this was done in GM5 where there was no image_angle to deal with then in GM6 when image_angle was introduced the optimisation obviously had to be removed but Mark forgot to remove it for the collision_* function checks.

Offline

#6 2009-06-13 22:38:13

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: collision_* - ignores image_angle if sprite/mask not transparent

All collision functions do that. If your instance rotates, YOU MUST have precision ON and you MUST have tranparent ON; the collision event is not affected by this (You can have precision ON and transparent OFF if you dont use collision functions or you dont rotate). I have a thread, 2 years old and other posts on the subject on the gmc.

For squares, add an extra raster (invisible) line to the bottom of your square sprite/mask.

If (precision is OFF or ((Precision is ON but transparent is OFF) and image_angle is not 0))
  {  BBOX defines the collision area }

Last edited by icuurd12b422 (2009-06-13 22:40:29)

Offline

#7 2009-06-13 23:44:55

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: collision_* - ignores image_angle if sprite/mask not transparent

icuurd12b422 wrote:

All collision functions do that. If your instance rotates, YOU MUST have precision ON and you MUST have tranparent ON; the collision event is not affected by this (You can have precision ON and transparent OFF if you dont use collision functions or you dont rotate). I have a thread, 2 years old and other posts on the subject on the gmc.

For squares, add an extra raster (invisible) line to the bottom of your square sprite/mask.

If (precision is OFF or ((Precision is ON but transparent is OFF) and image_angle is not 0))
  {  BBOX defines the collision area }

You repeated what xot's said in his first post...

Offline

#8 2009-06-14 22:54:41

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: collision_* - ignores image_angle if sprite/mask not transparent

Marchal_Mig12 wrote:
icuurd12b422 wrote:

All collision functions do that. If your instance rotates, YOU MUST have precision ON and you MUST have tranparent ON; the collision event is not affected by this (You can have precision ON and transparent OFF if you dont use collision functions or you dont rotate). I have a thread, 2 years old and other posts on the subject on the gmc.

For squares, add an extra raster (invisible) line to the bottom of your square sprite/mask.

If (precision is OFF or ((Precision is ON but transparent is OFF) and image_angle is not 0))
  {  BBOX defines the collision area }

You repeated what xot's said in his first post...

And you copied it... Ooops, so did I. This to say this bug was discovered a while ago...

Last edited by icuurd12b422 (2009-06-14 22:56:37)

Offline

Board footer

Powered by FluxBB