Scripting larping

Hi!
How do prefabs execute the lerp command after the deck book was selected.

How should the below section look like to work.

void deck_CardAdded(object sender, CardEventArgs e)
    {
        float co = cardOffset * deck.CardCount;
        Vector3 temp = start + new Vector3(co, 0f);
//"start" creates my book in static point A, but I want to insert animated from the larp script but I do not know how this part should look like
        AddCard(temp, e.CardIndex, deck.CardCount);
    }

This is the larp script;

using System.Collections;
using UnityEngine;

public class Lerp : MonoBehaviour
{
    /// The time taken to move from the start to finish positions
  
    public float TimeTakenDuringLerp = 0f;
    private bool _isLerping = false;
    private Vector3 _startPosition;
    private Vector3 _endPosition;

 
    private float _timeStartedLerping;
 
    public IEnumerator StartLerping(Vector3 endPosition)
    {
        if (_isLerping)
        {
            yield return null;
        }
        else
        {
            _isLerping = true;
            _timeStartedLerping = Time.time;

            _startPosition = transform.position;
            _endPosition = endPosition;

            float percentageComplete = 0;
            do
            {
             
                float timeSinceStarted = Time.time - _timeStartedLerping;
                percentageComplete = timeSinceStarted / TimeTakenDuringLerp;
                transform.position = Vector3.Lerp(_startPosition, _endPosition, percentageComplete);
                yield return null;
            } while (_isLerping && percentageComplete < 1.0f);
            _isLerping = false;
        }
    }

    public void StopLerping()
    {
        _isLerping = false;
    }


    //We do the actual interpolation in FixedUpdate(), since we're dealing with a rigidbody
    void aFixedUpdate()
    {
        if (_isLerping)
        {
          
            float timeSinceStarted = Time.time - _timeStartedLerping;
            float percentageComplete = timeSinceStarted / TimeTakenDuringLerp;

            transform.position = Vector3.Lerp(_startPosition, _endPosition, percentageComplete);

            if (percentageComplete >= 1.0f)
            {
                _isLerping = false;
            }
        }
    }
}

That Lerp script operates on the GameObject that it is placed on. Put it on the object you want moved and then call StartCoroutine(StartLerping(destinationVector3)); from any script.

Alternately there’s a bunch of tweening asset packages in the asset store that do this and have editor hookups of varying qualities and capabilities to help you set up scenes.