Reputation: 1
I am trying to get the position of the parent object but instead of returning its real value (0,80) in this case, it returns (0,0) This is the code for getting the position:
extends Node
var og_position:Vector2
var og_scale:Vector2
var og_rotation:float
var og_size:Vector2
@onready var animObj = get_parent()
func _ready():
_set_originals()
func _set_originals():
og_position = animObj.position
og_scale = animObj.scale
og_rotation = animObj.rotation
og_size = animObj.size
# Debug
print(og_position)
print(og_scale)
print(og_rotation)
print(og_size)
attached image
An image to describe the problem
I want og_position to return me the value (0,80), the relative position of the parent object.
EDIT: I'm thinking it's a godot problem, because if I put the code “og_position = animObj.position” it gives me (0,80), but in the ready it's still (0,0).
Upvotes: 0
Views: 445
Reputation: 136
You can use global_position
and all other transform properties are in global_*, such as global_transform
, global_mouse_position
and so on. This properties gives you that property relative to your main running game scene.
Upvotes: 0