• 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!

Legacy GM instance_place and hitbox issues

Hello there i seem to be having a problem with instance_place collisions. I've decided to move away from the collision events and move everything over to the step event.

I've run into a small issue however. Back then when i used the collision event. I would change the image_xscale of a hitbox to get accurate hit detection. But i can't seem to replicate that effect now.

Whenever the player is facing right the hit detection works perfectly. However when the player is facing to the left and the image_xscale is flipped the hitbox detection still occurs as if the player was still facing right. Now this only happens when the player is close enough to the enemy and acts as if hitbox was not flipped.

Here's my code and how i've set it up, as in the help file. Is there something i'm missing here?


Code:
var hitbox=instance_place(x,y,hitter)
if hitbox!=noone
{
  do this
}
 

Ido-f

Member
I would like to see someone give a better solution.
Ideally the collision mask should change to fit the image_scale values in my opinion.
But it can be solved I believe by setting the sprites' origin at their middle center.
 

Bentley

Member
Is the player's origin centered, the hitbox's origin centered, and are you setting its image_xscale to the xdirection you're facing?
 
Is the player's origin centered, the hitbox's origin centered, and are you setting its image_xscale to the xdirection you're facing?
Yes the image_xscale is wherever the player is facing -1 = left 1=right


I would like to see someone give a better solution.
Ideally the collision mask should change to fit the image_scale values in my opinion.
But it can be solved I believe by setting the sprites' origin at their middle center.
No matter what you'd still have to find the offset in which a Hitbox occurs. However I figured out why this is happening. When I create the AtkObj i do something like

atk=instance_create(x,y,AtkOBJ)
atk.image_xscale=image_xscale.

While it is true that it does work. All objects are created at default values aka image_xscale will always be 1 upon creation no matter what. Therefore before the actual Hitbox is kept at 1 until it's fully initalized. What I ended up doing is moving the Hit stuff to the end step as it waits for everything to be completed first before doing the collision checks.
 
Top