유니티 심화

Lerp

다모아 2023. 8. 17. 15:31

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LerpMain : MonoBehaviour
{
    [SerializeField]
    private Transform startTrans;
    [SerializeField]
    private Transform pointTrans;
    [SerializeField]
    private Transform endTrans;

    [SerializeField]
    [Range(0, 1)]
    private float lerpValue;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 tpos = Vector3.Lerp(this.startTrans.position, this.endTrans.position, this.lerpValue);

        this.pointTrans.position = tpos;
    }
}