Strange issue with pathfinding on copied object

I have an enemy gameobject with AI Destination Setter, AIPath, Seeker, and Funnel scripts attached. The target is my player object. One the player shoots the enemy, the AIPath script is enabled and the enemy draws a path and moves towards the player. This works fine.

However, a copy of the enemy gameobject does not work. If I shoot the copied enemy first, it does nothing. Once I shoot the original enemy, they both move towards the player. The original enemy works fine.

Everything looks as it should in the inspector for the copied enemy. Any ideas?

Hi

Do you think you could show the code that you use to set the destinations?

Sure

public AstarPath AstarPath;
public Seeker seeker;
public Path path;
private AIPath pathscript;

void Start(){
    seeker = GetComponent<Seeker>();
    pathscript = GetComponent<AIPath>();
}

void Update(){
    if(isAlerted == true){
        Charge();
    }
}

void Charge(){
    animator.SetBool("isRunning", true);
    pathscript.enabled = true;
}

void Hit(){
    isAlerted = true;
}

The AIDestinationSetter script has my player set as the target.

Could you verify that both the animator, pathscript and seeker are pointing to the correct agent.

Also double check if Hit is being called on the correct agent.

1 Like

Weird, deleting and recopying the object seemed to fix it. Thanks!

2 Likes