Rotation is not through the center

Hi guys.
Thanks in advance for my english.
The question is as follows. How to make the rotation of the sprite relative to its coordinates, and not the center of the sprite? For example, the gun on the tank does not turn as I need, how to fix it?%D1%81%D0%BA%D1%80%D0%B8%D0%BD

Welcome Tactics,
You can change how a sprite rotates by setting the origin.

1 Like

If your gun is a separate sprite, try using .setOrigin(x,y) where you replace the x and y with how far from the top left corner you want the pivot point to be.

.setOrigin(0,0) would make the pivot in the top left
.setOrigin(0.5,0.5) would make the pivot in the center
.setOrigin(1,1) would make the pivot in the bottom right

I hope this makes sense.

1 Like

Thank you very much guys

1 Like