Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
879 B
2
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CarFallow : MonoBehaviour
{

    public List<Vector3> positions;
    public List<GameObject> obje;
    
    void Start()
    {
        Application.targetFrameRate = 60;
        for (int i = 1; i < obje.Count - 1; i++)
        {
            positions[i] = obje[i].transform.position;

        }
    }
    void LateUpdate()
    {

        for (int i = 0; i < obje.Count; i++)
        {
            positions[i] = obje[i].transform.position;

        }
        for (int i = 1; i < obje.Count; i++)
        {
            obje[i].transform.position = Vector3.Lerp(obje[i].transform.position, new Vector3(positions[i - 1].x, 0f, positions[i - 1].z + 0.5f) + new Vector3(0, 0, -8), 5f * Time.fixedDeltaTime);
        }

    

    }
}