• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML How to create a 360 degrees collision box?

E

Edwin

Guest
I'm trying to implement a collision box that game will create by rotating the image angle. This could be very helpful for TDS games, cuz player will overlay the wall after changing it's image angle and stuck inside. Is there a way to do that?
 

marasovec

Member
Don't rotate the bbox with image_angle. Rotate the just the sprite instead with a different variable. For example I use "img_angle"
Draw event:
Code:
draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, img_angle, c_white, image_alpha);
 
C

CedSharp

Guest
Don't rotate the bbox with image_angle. Rotate the just the sprite instead with a different variable. For example I use "img_angle"
Draw event:
Code:
draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, img_angle, c_white, image_alpha);
To go into more details with his answer, basically when you call sprite_draw_ext() you aren't affecting any of the game_maker built-in variables, you are effectively only drawing the sprite and no collision bug should happen!

As @marasovec mentioned, you can create your own variable, like "img_angle" and then change that variable to fake the rotation (which will just be visual, and the collision box will continue to be "normal" without rotation).
 
S

spoonsinbunnies

Guest
for this reason most top down games the actual collisionmask of the character is usually a circle encompassing the head.
 

TheouAegis

Member
for this reason most top down games the actual collisionmask of the character is usually a circle encompassing the head.
Yeah, but unfortunately that doesn't even work in Game Maker. Even with a circular mask, modifying image_angle will shift the mask and result in false collisions. Unfortunately, image_angle is not a good variable to mess with.
 
Top