Global_position, position

Godot Version


Even if I change position to global_position the laser still doesn’t appear/come out of the same place on the screen. Heelp ;-;

After 2 hours of trying to solve it and giving up >>>>>> now the grenades also doesn’t appear/come out of the same place.

Taken from my comment on a video

Hi there!
Please provide more information, we can’t help you without knowing your scripts and so on.

1 Like

it could be because you are working with local position.
please use and read about it.

var posGlobal: Vector2 = get_global_transform().get_origin()

it is going to give you the global position of the node.
if this node is part of another node you make sure this one is placed at origin coordinate because this node could be in other position (offset)

that code is equivalent to just using global_position directly, you don’t need to get it via the transform

but how do you access this (global_position) without using the other ( get_global_transform). If you have a better asnwer I would like to know it, I like to learn a lot. Thanks.

Thanks for trying to help, I finally found the error, I was using Node instead of Node2D, what a mistake :new_moon_with_face:

Captura de tela 2024-04-13 104356

1 Like

Node2D and Node3D has a global_position property, it’s basically a shorthand to global_transform.origin, it’s new to Godot4 if I remember correctly.

1 Like

Since this question is about Godot 4: just use global_position, it is a property of every Node2D/Node3D.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.