0 votes

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

func getinput():
var mouse
position=getlocalmouseposition()
var angle=angle
topoint(mouseposition)
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.

asked Jun 2 in Projects by zoenel (17 points)

2 Answers

0 votes

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

answered Jun 2 by drorya (144 points)
0 votes

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()) )

answered Jun 2 by estebanmolca (1,203 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.