熟悉c#中。。。
实现的功能是简单的相机的跟随的效果
代码如下:
using UnityEngine;
using System.Collections;
public class TargetFollower : MonoBehaviour{
public Transform Target_char;
public float smoothTime = 0.01f;
private Vector3 cameraVelocity = Vector3.zero;
private Camera mainCamera;
void Awake ()
{
mainCamera = Camera.main;
}
void Update()
{
transform.position = Vector3.SmoothDamp(transform.position, Target_char.position + new Vector3(0, 0, -5), ref cameraVelocity, smoothTime);
}
}
效果如图,相机会跟随物体移动。修改参数可以调整跟随的速度。