Cannot move objects between 2 different terrain objects in the same Scene

Working on an RTS where my workers must gather resources and return them to their “home base”, a Fort.

The Fort is a totally separate area/view than the world. For example, a worker gathers berries in the world, then moves back to the Fort object. In the outside world view, the Fort appears small, just a cube object at the moment. When the worker collides with the Fort cube object, he should be taken to the Fort area/view that has buildings, a market, etc.

So simultaneously, there are workers inside the Fort view and outside in the world view.

The player should be able to switch back and forth between the outside world view and the Fort view quickly.

The outside world terrain object starts at (0,0,0) and Fort terrain object starts at (0,0,35), so I’m working with small areas just prototyping. There is a small gap between them.

Currently I am simply trying to “teleport” the worker object from the cube Fort in the world view to a specific position in the Fort view…transform.position = new Vector3(-15, 0, 50);

But when I do this, the worker is blocked by the boundary of the world view and stays on the world terrain object. I cannot move him over to the Fort terrain object. Not sure if this is NavMesh related or what. I have the NavMesh baked for both areas and if I just drop a worker in the Fort, he wanders fine.

  • Should the outside world view and the Fort view be 2 separate areas within 1 scene? Maybe this is not how I should be setting this up.

  • How else should I have 2 simultaneous areas like this? 2 separate scenes that run at the same time? Is there another way?

Hope I explained this well. Thanks for any thoughts!

I don’t have a lot of experience with NavMesh but it sounds like it could be related. I’ve had similar issues with CharacterController though and used a workaround like this:

public void TeleportTo(Vector3 position) {
  myCharacterController.enabled = false;
  transform.position = position;
  myCharacterController.enabled = true;
}

Maybe something similar would work with NavMeshAgent?

Alternatively, try the Warp method on NavMeshAgent?

1 Like

Yes! Warp worked like a charm. Thank you so much. var nm = GetComponent<NavMeshAgent>().Warp(entryPoint.Value);