Untitled
unknown
plain_text
2 years ago
695 B
10
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class FruitAI : MonoBehaviour
{
public Transform playerTransform;
NavMeshAgent agent;
Animator animator;
// Start is called before the first frame update
void Start()
{
agent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
agent.destination = playerTransform.position;
animator.SetFloat("Speed", agent.velocity.magnitude);
float speed = agent.velocity.magnitude;
Debug.Log(speed);
}
}
Editor is loading...
Leave a Comment