Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AI;
- public class Enemy : MonoBehaviour
- {
- private Transform playerTransform;
- private NavMeshAgent nma;
- private Animator anim; // НОВОЕ
- private void Awake()
- {
- playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
- nma = GetComponent<NavMeshAgent>();
- anim = GetComponent<Animator>(); // НОВОЕ
- }
- private void Update()
- {
- nma.SetDestination(playerTransform.position);
- anim.SetFloat("Speed", Mathf.Lerp(0f, 1f, nma.velocity.magnitude / nma.speed)); // НОВОЕ
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement