- Home /
A* Follow in runtime
With the A* path finding component, I can move gameobjects from point A to B. For example in the Start() method:
seeker.StartPath( transform.position, target.transform.position, OnPathComplete );
My question is: How would I make it possible to recalculate the path everytime gameObject B moves, so that GameObject A will always chase GameObject B?
My idea was to recalculate the path every variable in time, like:
void Recalculate (){
//If gameobject is moving and cooldown is < 0
//Recalculate the Path
//Set some kind of cooldown
}
However, this gives enormous framerate drops. I hope you can point me in the right direction on the algorithm needed for this. Thanks for reading!
I am not sure if I get this right but you could try parenting GameObject B to GameObject A in a script, like
GameObjectA.parent = GameObjectB;
You can check the Unity S$$anonymous$$lth Project for some tips. You need the DoneEnemyAI.cs and DoneEnemySight.cs scripts. The enemy is navigating to the character on sight using a Nav$$anonymous$$eshAgent. Sorry mate, I haven't done anything like this before, and I can't help you properly, but at least you can check their code.
Your answer
