How can I have duel wielding guns anchored to player but also rotate independently towards mouse?

Godot Version

4.3

Question

I’m making a top down shooter with the player having a weapon in each hand. Currently the bullets fire from each hand (from a Marker 2D location) and rotate with the player as they should. The player currently faces the mouse so, as expected, the bullet fire towards the mouse as well because they are technically facing the same direction as their parent. In addition to the weapons being anchored to, and rotating with the player, is it possible to have them adjust their own independent facing direction to angle inwards to shoot directly at the mouse cursor, rather than in the direction of it? Yes, the parent is looking directly at the mouse but because the weapons are off to the left and right of the center of the parent, they fire in that direction but they go to the left and right of the cursor, parallel to the center line. So the closer an enemy is to the player, the more of an inward angle I’m trying to make the weapons point, otherwise they shoot right past the enemy on both sides.
I’m sorry if that was a terrible explanation! I’m still rather new to Godot, coming from a Unity background I’m still figuring out all the possibilities with GDScript but really enjoying it so far!
Any advice would be much appreciated!!

Why can’t you rotate the weapons?

Currently I’m using “look_at(get_global_mouse_position())” for the player to face the mouse and I tried also using look_at with each of the Marker2D weapons and they don’t move. Is this some sort of override issue or should the weapons have their own children and try to rotate those?

You should be rotating the root Node of the Weapon, not just the Marker2D (unless the Marker2D is a parent Node of the Weapon?)
Show your scene structure and code, it’ll be easier to help you.

2 Likes

That’s exactly what it was, I was trying to rotate the Marker2D itself…rotating the parent node works just fine. Thanks so much!

1 Like