1. 程式人生 > >Unity跟隨目標物體的效果

Unity跟隨目標物體的效果

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

public class XianFollow : MonoBehaviour {
    private bool kaishi = false;
    private Transform tr;
    public void startFollow(Transform mm)
    {
        kaishi = true;
        tr = mm;
    }

    private void Update()
    {
        if (kaishi)
        {
            transform.position = tr.position;
            transform.rotation = tr.transform.rotation;
        }
    }
}

 

上面程式碼實現  自身時刻的跟隨目標


FR:海濤高軟(hunk Xu)
QQ技術交流群:386476712