Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created August 3, 2016 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/c8d15f5959a474f1b62f2a2d6a318d12 to your computer and use it in GitHub Desktop.
Save tsubaki/c8d15f5959a474f1b62f2a2d6a318d12 to your computer and use it in GitHub Desktop.
目標地点に近づいたら、目標地点を更新する
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SimpleLookat : MonoBehaviour {
// ゴール
[SerializeField] List<Transform> targets;
// カーソル
[SerializeField] Transform cursor;
IEnumerator<Transform> currentTargets;
Quaternion offsetRotation;
void Start()
{
currentTargets = targets.GetEnumerator();
currentTargets.MoveNext ();
}
// Update is called once per frame
void Update ()
{
if (Vector3.Distance (transform.position, currentTargets.Current.position) < 3) {
currentTargets.MoveNext ();
}
cursor.LookAt (currentTargets.Current);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment