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.

in Engine by (17 points)

2 Answers

0 votes

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

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

by (2,060 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.