G
Gabriel Rudas Burgos

How "global_postion" works?

When calculating the target angle there is this line:

target_angle = target.global_position.angle_to_point(global_position)

I understand that the firs ".global_position" is a property of "target" (where the node is located in absolute terms) . However, when you pass "global_position" as an argument, what does it mea? What is this second " global_position" refer to? Is it the same as "target.global_postion"?

In the explanation you say

With two Vector2 coordinates, A and B, you can calculate the angle from point A to point B by calling A.angle_to_point(B).

If "target.global_position" is point A, how is that "global_position" is also B?

  • Nathan Lovato replied

    When you write position or global_position, or rotation or any other node property alone like this, it means "the global_position of the node to which I attached this script file." In this context, it is the global position of the Turret node.

    1 love