I want that the x value of a region rect of a sprite is set to the x position of a KinematicBody2d divided by 10 plus 52 and the same with the y value of the region rect.
I tried this:
get_node("Sprite").region_rect =
Rect2(get_node("KinematicBody2d").position.x / 10 + 52,
get_node("KinematicBody2d").position.y / 10 + 52)
#In the real code this is all in one row
But I got this error:
Invalid type in 'Rect2' constructor. Cannot convert argument 1 from Nil to Vector2.
How can I fix that?
Thanks for answers.