Godot Version
Godot 4.2.1
Question
Hello, this is the first time I’m doing game development. I had a problem with the lerp() function. I was making zipline mechanics. When I put the lerp() line code in the zipline script for the sliding thing, the player will slide into the end point of the zipline. But the movements are instantaneous.
Here’s my code for Ziplines.
extends Node2D
@onready var playerchar: CharacterBody2D = get_node("/root/level/player")
@onready var startrope: Vector2 = $start.position
@onready var endrope: Vector2 = $end.position
@export var rope_color: Color
@export var rope_width: float
@export var rope_speed: int
func _ready():
pass
func _draw():
draw_line(startrope,endrope,rope_color,rope_width,true)
$start/point.modulate = rope_color
$end/point.modulate = rope_color
func start_zipline():
playerchar.position = lerp(startrope, endrope,0.5)
func _on_start_body_entered(body):
if playerchar == body:
start_zipline()
pass
And this is the one-line code of usage lerp().
playerchar.position = lerp(startrope, endrope,0.5)
Are there any ideas for solving the problems?