GameMaker Turret rotation not centered(even with correct origin)

L

LegendaryBananaSlayer

Guest
Hello everyone!

I am making a pixelated space game(my first game, if we are not including games following tutorials :D), and on top of the ship there is a turret mounted to it. I have set the turret to rotate towards the mouse using point_direction(mouse_x,mouse_y), and to follow the ship using turret.x = x, turret.y = y. However, when I rotate the turret, it seems like the turrets origin is slightly off. Its like this: when both the turret and the ship is facing the same direction, the origin is perfect. but when the turret is facing the opposite direction, the origin of the turret is off. It makes no sense.

It follows the ships angle respectively like this:
when the ships facing right(image_angle 0) and turrets facing left: the turrets origin is at -1y (one pixel up)
when the ships facing left(image_angle 180) and turrets facing right: the turrets origin is at +1y(one pixel down)

It might be worth noting that i made the sprites an odd number to place the origin in the exact middle. (33 x 33 for the ship, 17 x 11 for the turret).

I am really struggling with this, it does not seem like a common problem. Thanks for any help!
 
L

LegendaryBananaSlayer

Guest
You actually need an even number of pixels for the origin to be exactly centered. That's probably all that is wrong.

Here is a post with some images to illustrate why.
oh. my. god. it worked. At first I placed the origin one pixel up and one left, wich only worsened it. But when I placed it one pixel down, one right it worked. It is perfectly alligned. Thank you so much!
 
Top