Weapon rotation, based on mouse position

Godot Version

4.3

Question

Hey, I’m pretty new to Godot. I wanted to make an aiming system similar to Enter the Gungeon.
The problem is: When I try to aim the melee weapon hitbox (CollisionShape2D) towards the mouse, it does not pivot from the player’s position, rather from the hitbox’s original position, it’s supposed to move kind of like how clock hands rotate around the center of a clock.
I’ve looked everywhere for a way to change the pivot point of the CollisionBox, but I’ve had no success, does anyone know how?
Thanks

Instead of rotating the collision box rotate the area2D its attached to

this might help you

rotate(get_angle_to(get_global_mouse_position())+offset)

and for “pivot point” you could use a node2d or something and rotate that
image
hope this helps

1 Like

Tysm, It works, kind of. It actually aims in the opposite direction of the mouse, but I’m sure I can figure that out on my own.
Thanks again

no problem, and for that opposite direction issue, rotate the pivot node children or set that previously mentioned offset to 180