Seeker teleporting to where my player died

Hi @aron_granberg,

At the moment I have a click and walk configuration that uses the AILerp script and everything works fine until my player dies.

What I do is, I teleport the player to the nearest graveyard using transform.position and this part works fine but as soon as the player clicks on any place on the map, the seeker teleports him back to where he died.

Is this something that could be done using the free version of A*? I know the pro version has a teleport option but I am almost done with my alpha and I don’t know if upgrading my A* is an option (even to the beta free)

I hope you can help me,

I narrowed it to this function inside the AILerp script: CalculateNextPosition(out Vector3 direction)

Is this the correct behaviour? Why is it so complicated to move my gameObject and let the script recalculate the path from wherever the gameobject is?

I think I made it.

closestGY --> Closest Graveyard

canMove = false;
tr.position = closestGY;
nextPos = closestGY;
target = closestGY;
canMove = true;

This took me more than 20h to figure out and I am still not sure if its working because it should or because of delay/luck.

I would like @aron_granberg to confirm if this is the correct way of “teleporting” a seeker using the AILerp script.



Sorry for the late answer.
The intention was that disabling the object and moving it to a new position and then re-enabling it (as is a very common pattern when pooling or respawning an object) would just work. Unfortunately in the current version it doesn’t work as intended.
It does work exactly like this in the beta (or you can use the Teleport method which allows you to move it without disabling the object). So if you can upgrade to the free beta then it would work.

Here is the AILerp script from the beta:
I stripped out some things that will not compile in your version, but I think it should compile now. You can try it and see if it works better. Since it’s the beta I am not 100% sure that I haven’t recently broken some important functionality in it, but I think it should work well.

Thank you @aron_granberg, I will try this and get back to you ASAP.