Created
August 3, 2016 15:07
-
-
Save tsubaki/c8d15f5959a474f1b62f2a2d6a318d12 to your computer and use it in GitHub Desktop.
目標地点に近づいたら、目標地点を更新する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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