#Convert a global mouse position to a local position for Raycast2d
1 messages · Page 1 of 1 (latest)
Still getting the same issue were the vector will appear opposite of the clicks.
extends Node2D
var radius_range = 75
var is_ready: bool = true
#Handles Teleportation
func _input(event):
if event.is_action("Click"):
var mouse_pos = get_global_mouse_position()
$RayCast2D.target_position = get_parent().to_local(get_global_mouse_position())
$RayCast2D.force_raycast_update
if mouse_pos.distance_to(get_parent().global_position) < radius_range and is_ready and !$RayCast2D.is_colliding():
is_ready = false
$CooldownTimer.start()
get_parent().global_position = get_global_mouse_position()
func _draw():
draw_arc(position, radius_range, 0, deg_to_rad(360), 100, Color.FLORAL_WHITE)
func _on_cooldown_timer_timeout():
is_ready = true