- Home /
Question by
EinfachFinn · Jan 07 at 01:30 AM ·
c#aiscripting beginnerbeginnerpathfinding
AI Pathfinding script with Speed Adjustment
Hello, I am new to unity and have copied a Pathfinding script from this video: https://youtu.be/atCOd4o7tG4
But the agent runs way too fast. How can I make the speed of the agent be the float speed. I appreciate any response, thanks in advance
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class EnemyNavMesh : MonoBehaviour {
public float speed;
[SerializeField] private Transform movePositionTransform;
private NavMeshAgent navMeshAgent;
private void Awake(){
navMeshAgent = GetComponent<NavMeshAgent>();
}
private void Update (){
navMeshAgent.destination = movePositionTransform.position;
}
}
Comment
Best Answer
Answer by KloverGames · Jan 08 at 11:11 AM
float botSpeed = 10f; navMeshAgent.speed = botSpeed;