• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Hitbox and image scale

KKf

Member
Is there a way to scale the image but keep the hitbox? I want to make a script animation that makes an object shrink and elongate when the player hits it with his body, and making it shrink with the commands "image_xscale and image_yscale" makes my player "stick".
 

DaveInDev

Member
WIth no guaranty, I will
1- try to change the "collision mask" default "same as sprite" to a copy of the same sprite, that will maybe keep its own scale when you resize the main sprite.
2- if it does not work, you can still use the draw event, with a draw_sprite_ext that will overwrite the draw_self() call and scale the main sprite without using image_xscale
 

TheouAegis

Member
To translate point 2 (I didn:t understand point 1), make a new variable scale and set it to 1 by default. Add a Draw event and in it put

draw_sprite_ext(sprite_index,-1,x,y, scale, scale,image_angle, image_blend, image_alpha);

Instead of changing image_xscale, change scale.
 
Top