Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hermo |
Hello!
I have my game structured like this:
- level
-
- item (position2D)
-
- player (position2D)
.
I have a script in player and I want to draw a line between item and player, the line should update as the player moves (item will be static), like they were tied by a rope.
.
This is the script in player:
onready var item = get_parent().get_node(‘item’)
func _physics_process(delta):
update()
func _draw():
draw_line($player.position, item.global_position, line_color, line_width)
.
The problem is that the line gets drawn from the player (correct) but instead of going to the point where is the item (in this case in point (200, 100)) it gets drawn just 200 pixels to the right and 100 down where the player is.
What should I do???
Thank you!!!