Expectation:
The tween is supposed to move the object between two positions.
These positions are below and above the movable object.
The object is supposed to tween up, then tween down to the second position, and repeat.
Issue one:
Only tweens to the first position without tween.kill().
First position
tween.tween_property(self,“position”,Point_1.get_position(),0.5).set_delay(0.2)
When I try to kill the tween normally, it doesn’t play (because the tween never started, I’ve tried putting Tween.kill() under the property before, it still just stops it from playing entirely)
Issue two:
When killing the tween via player collision, instead of following the player like it’s supposed to
the second tween starts, and never transitions back the first property.
Second position
tween.tween_property(self,“position”,Point_2.get_position(),1.5)
The overall issue is that the tween doesn’t switch between property methods
Which in return leads to the object not following the player.
My bad for making it sound confusing, I rushed while writing it the first time.
CODE BELOW:
extends RigidBody2D
var float_up :bool = false
var float_down: bool = false
var is_in_grab_zone: bool = false
@export var Point_1: Node
@export var Point_2: Node
@onready var Up_T = $"Up_timer"
@onready var Down_T = $"Down_timer"
@onready var sling = get_node("../../Sling")
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(_delta):
var tween = get_tree().create_tween().set_loops()
if is_in_grab_zone == true:
tween.kill()
self.position += sling.position - position
if tween.finished:
tween.kill()
tween.tween_property(self,"position",Point_1.get_position(),0.5).set_delay(0.2)
tween.tween_property(self,"position",Point_2.get_position(),1.5)