H_SafeExperienceDrivingSystem/U3D_DrivingSystem/Assets/Script/Objective/FollowCar.cs

22 lines
438 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowCar : MonoBehaviour
{
public Transform target;
private Vector3 offset;
// Use this for initialization
void Start()
{
offset = target.position - this.transform.position;
}
// Update is called once per frame
void Update()
{
this.transform.position = target.position - offset;
}
}