- Edited
I'm currently working on my ai and am needing some help as I'm converting my game from Game Maker to Godot and so far it's been pretty easy and GDScript's pretty easy to grasp but I have a few questions.<br><br>How do you check the distance from Node A to Node B?<br>In game maker there's a distance_to_object or point_to_distance(which I use) and a point_direction function.<br><br>Now I have tried and created a distance to function.<br>
func distance_to(n1,n2):<br>#Player node<br><br>n1=get_node("Player")<br><br>#Enemy or NPC node<br><br>n2=get_node("Enemy")<br><br>#get how far n1 is from n2 or vice versa<br><br>var xdist=n1.x - n2.x <br>var ydist=n1.y - n2.y<br>return (xdist xdist) + (ydist ydist)For point_direction "gml, kinda long and would take awhile to edit to gdscript" and also a vector based direction function "I'd write it as a function".<br><br>Vector version: direction=rad2deg(atan2(vec1.y - vec2.y, vec2.x - vec1.x))<br><br>GML "to be changed later?"<br><br>x1=argument0; <br><br><br>