Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using System.Collections;
public class Follow : MonoBehaviour {
public GameObject target;//ターゲット(追尾対象)格納変数
public float cameraSpeed;//スピード(カメラの速さ)格納変数
Vector3 distance;//距離(ターゲットとどれくらいの距離を保つか)格納変数
// Use this for initialization
void Start () {
distance = target.transform.position - transform.position;
// Update is called once per frame
void LateUpdate () {
Vector3 cameraDistance = target.transform.position - distance;
transform.position = Vector3.Lerp (transform.position,cameraDistance,Time.deltaTime * cameraSpeed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment