Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Robot : MonoBehaviour {
- public Transform target;
- NavMeshAgent agent;
- Animation avatar;
- // Use this for initialization
- void Start () {
- agent = GetComponent<NavMeshAgent>();
- avatar = GetComponentInChildren<Animation>();
- }
- // Update is called once per frame
- void Update () {
- agent.SetDestination( target.position );
- if ( agent.velocity.magnitude > 0.1f )
- {
- avatar.CrossFade("run");
- } else {
- avatar.CrossFade("idle");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment