There is no argument given that corresponds to the required formal parameter 'newPosition' of 'NavMeshAgent.Warp(Vector3)'
I'm making a little fps game. So I have enemies that follow the player, original prefab can follow player normally, but when I make copies they just come to original position where player spawned on, and I'd get this error which is the title of this question. I used Warp(); function, but it seems it didn't helped or I used it incorrectly, I rebaked the NavMesh over and over again to see if that will help but it didn't, the agent is bounded to the NavMesh, but still I'm not sure what should I do in this kind of situation. Here's the code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
public class enemyMovement : MonoBehaviour
{
public int stoppingDist;
public float coolDown;
public float lastAtt;
public int enemyDmg;
public NavMeshAgent agent;
public GameObject target;
public Vector3 newPosition;
private void Start() {
if (agent == null)
{
agent = GetComponent<NavMeshAgent>();
target = GameObject.FindGameObjectWithTag("Player");
}
}
private void Update()
{
float dist = Vector3.Distance(transform.position, target.transform.position);
if(dist < stoppingDist){
Stop();
if(Time.time - lastAtt >= coolDown){
lastAtt = Time.time;
target.GetComponent<playerHealth>().DealDamage(enemyDmg);
}
}else{
MovingToTarget();
}
}
private void MovingToTarget(){
agent.isStopped = false;
agent.Warp(newPosition);
agent.SetDestination(target.transform.position);
}
private void Stop(){
agent.isStopped = true;
}
}
I followed tutorial on this link: https://www.youtube.com/watch?v=tVc3NnzKZ4E&list=PLKklF7YNi0lOM0C8r_L3JN3oTC6AY9iFE∈dex=61
Thanks in forward.
Your answer
Follow this Question
Related Questions
Why my second NavMesh Agent can't find the NavMesh? 1 Answer
Multiple AI agents going through the same Nav Mesh Link at the same time ? 1 Answer
Pros and cons to using Navmesh Agents over custom-made AI? 1 Answer
Problem with NavMesh 0 Answers
Occasional NavMeshAgent gets stuck and goes the wrong direction 1 Answer