Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 3, 2016 15:53
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/280167ea1a84f1eba0282d3dfbdd5a93 to your computer and use it in GitHub Desktop.
Save tsubaki/280167ea1a84f1eba0282d3dfbdd5a93 to your computer and use it in GitHub Desktop.
経路探索AIを用いてパスを表示する
using UnityEngine;
using System.Collections;
public class TanksLookTarget : MonoBehaviour {
[SerializeField]
Transform target;
[SerializeField]
Transform cursor;
[SerializeField]
NavMeshAgent agent;
void Start ()
{
agent.SetDestination (target.position);
agent.updateRotation = false;
agent.updatePosition = false;
}
void Update()
{
cursor.rotation = Quaternion.LookRotation (agent.steeringTarget - transform.position, Vector3.right);
agent.nextPosition = transform.position;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment