Hello, I need to write the script for making my moving platform reverse course when it receives the signal from the Area3D and then reset again. The script is on an elevator. I've only found info on platforms that are moving constantly. I want mine to only move when it detects the player. Here is the script:
extends AnimatableBody3D
@export var a := Vector3()
@export var b := Vector3()
@export var time: float = 2.0
@export var pause : float = 0.7
func _on_area_3d_body_entered(body: Node3D) -> void:
if body.is_in_group("Player"): # Replace with function body.
move()
func move():
var move_tween = create_tween()
move_tween.tween_property(self, "position", b, time).set_trans(Tween.TRANS_SINE).set_delay(pause)
await move_tween.finished
Originally, the script included below for endless repeating:
move_tween.tween_property(self, "position", a, time).set_trans(Tween.TRANS_SINE).set_delay(pause)
#await move_tween.finished
#move()
Can anyone help, please? Thanks.