i keep getting Parser Error: The method "angle_to_point" isn't declared in the current class.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zoenel

so i keep getting the error Parser Error: The method “angle_to_point” isn’t declared in the current class when i’m trying to run my game. here’s my code:

func get_input():
var mouse_position=get_local_mouse_position()
var angle=angle_to_point(mouse_position)
print(angle)

so what this code is trying to do is its trying to get the angle of the location of the cursor based on the player sprite but i can’t do that due to the error.

:bust_in_silhouette: Reply From: drorya

what is your script’s Node type?
(what does it extend?)

:bust_in_silhouette: Reply From: estebanmolca

It is used like this: Vector2.angle_to_point(Vector2)
If the script is in the player node you can use position:
var angle=position.angle_to_point(get_local_mouse_position())
or if player is a child:
var angle = $Player.position.angle_to_point(get_local_mouse_position())
In degrees:
var angle = rad2deg( $Player.position.angle_to_point(get_local_mouse_position()) )