Godot Version
4.3
Question
`how do I write a code that makes it so if a variable is increasing then do x and if it decreasing do y I cant make a delayed recording of it to my knowledge so unless its built in I dont know what to do I need it to tell my npc what direction to face im using lerp for direction this is my code:
extends AnimatableBody2D
@onready var raycast = $RayCast2D
var MOVE_SPEED = 1
var inray = false
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
var location: Vector2 = raycast.get_collision_point()
if raycast.is_colliding():
$AnimatedSprite2D.play(“run”)
position.x = lerp(position.x, location.x, delta * MOVE_SPEED)
if raycast.is_colliding() == false:
$AnimatedSprite2D.play("idle")
`