From 79a5fedf7879da9b2395305e1b47f43e55f6d2aa Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Sun, 9 Mar 2025 17:05:54 +0800 Subject: Initial commit. Prototype finished. --- GunRotation.gd | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 GunRotation.gd (limited to 'GunRotation.gd') diff --git a/GunRotation.gd b/GunRotation.gd new file mode 100644 index 0000000..5398519 --- /dev/null +++ b/GunRotation.gd @@ -0,0 +1,15 @@ +extends Node + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + var mouse_position : Vector2 = get_viewport().get_mouse_position() + var delta_x : float = mouse_position.x - $"..".global_position.x + var delta_y : float = mouse_position.y - $"..".global_position.y + + $"..".rotation = atan2(delta_y, delta_x) -- cgit v1.2.3