From 3ddfffbd222419aef3ca91318323dd13de5aafc6 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Mon, 11 Jul 2022 20:58:10 +0300 Subject: [PATCH] [3.x] Fix click-and-move example --- tutorials/2d/2d_movement.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index ec07d81ae..e12cc8795 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -295,7 +295,7 @@ on the screen will cause the player to move to the target location. export (int) var speed = 200 - var target = Vector2() + onready var target = position var velocity = Vector2() func _input(event): @@ -317,9 +317,14 @@ on the screen will cause the player to move to the target location. { [Export] public int speed = 200; - public Vector2 target = new Vector2(); + public Vector2 target; public Vector2 velocity = new Vector2(); + public override void _Ready() + { + target = Position; + } + public override void _Input(InputEvent @event) { if (@event.IsActionPressed("click"))