Support Forum

Teleport Not Working all the time


I’m using IAstarAI and I’ve got some issue with the Teleport function. It seems to be very hit & miss, sometimes it works fine and other times it doesn’t.

I’ve got my AI being pooled at the start of the game & are initialized at & then disabled.

I then spawn them where I want, later on, to do this I spawn them from the pool & then use Teleport to move them. This generally works, but for some reason, some AI will just no teleport, even though when i debug log them, the location being sent to Teleport is correct.

When they are spawned from the pool I’m setting the values as seen below;

        this.agent.canMove = true;
        this.agent.canSearch = true;
        this.agent.isStopped = true;

Then the teleport code is:

        this.agent.canSearch = true;
        this.Destination = origin;
        this.agent.destination = origin;

If I spawn 100 AI, with a small delay in between spawning, most of them will spawn fine, but there is always some who don’t teleport…

Should I be setting some other value just before teleporting them?

Thanks for any help!


Which movement script are you using?
Could you log for example
Debug.Log(this.agent.position + " " + origin);
right after you try to teleport the agent?

I’m using the AIPath script for movement.

When I use that debug.log both values are the same, but the AI’s position clearly isn’t correct.

Exact code:
public void Spawn(Vector3 origin, Quaternion rotation)
this.MovementSpeed = Random.Range(this.minMoveSpeed, this.maxMoveSpeed);
this.agent.canSearch = true;
this.Destination = origin;
this.agent.destination = origin;
Debug.Log(this.agent.position + " | " + origin);
this.transform.rotation = rotation;

DebugOutput with the input of (16.2, 4.2, 13.1)

  • (16.2, 4.2, 13.1) | (16.2, 4.2, 13.1)

After more debugging, it appears to happen on the frame after they teleport. I have no other functions being used to move it after it teleports.


Try to disable all other components on the agent and see if it still happens. I’ve been looking through the code, and I cannot find anything that would cause this.


So made a simple test movement script & have the same results. Below is my exact code & I attached it to an object in a new, empty scene and have no other script attached. When pressing the teleport key the NPC would sometimes teleport with no issues, but most of the time it would teleport on 1 frame & then go back to its old position on the next frame.

I can send a GIF/Video if you would like.

Scripts Attached:

  • Seeker
  • AIPath
  • CharacterController
  • My Test Script, see below.

public bool canMove = true;
public Transform targetPosition;
public Transform teleportPos;
private IAstarAI agent;

public void Start()
    agent = GetComponent<IAstarAI>();

public void Teleport()
    canMove = false;
    agent.destination = this.teleportPos.position;
public void Update()
    if (Input.GetKeyDown(KeyCode.U))

    if (canMove)
        agent.destination = this.targetPosition.position;


I downloaded the script and tested it, but unfortunately I cannot replicate the behavior. For me, it works perfectly every time :confused:

After some more testing, it’s the CharacterController causing the issue.

If I remove it and try it, I get no issues.

1 Like