Godot Version
4.3
Question
extends Node2D
var arm_length = 0 # Fixed arm length (adjust as needed)
var arm_socket_offset:Vector2 = Vector2(8, -24)
# Variable to throttle mouse updates
var mouse_update_delay = 0.1 # Update every 0.05 seconds (20 updates per second)
var time_since_last_update = 0.0
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if time_since_last_update < mouse_update_delay:
pass
look_at(get_global_mouse_position())
func _process(delta: float) -> void:
time_since_last_update += delta
Using the script above to get the mouse position and rotate an objects is extremely laggy for some reasons. Here is a video showcasing the lag: