Godot Version
4.6.2
Question
Currently if you jump with the player controlled CharacterBody2D on the platform, it just slides away under you. How can I “stick” the player to it so you dont fly off
extends AnimatableBody2D
@export var pos1 : Vector2
@export var pos2 : Vector2
@export var duration = 2.0
var waspos1 = true
var previous_position : Vector2 # NEU
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
position = pos1
move(pos2)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func move(target: Vector2):
if target == pos1:
waspos1 = true
else:
waspos1 = false
var tween = create_tween()
tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
tween.tween_property(self, "position", target, duration)
if waspos1:
tween.tween_callback(move.bind(pos2))
else:
tween.tween_callback(move.bind(pos1))


