So I have an MMORPG in the works in unity 3.5.
I use Navmesh Navigation for walking.
I also have it set up as a server and client.
I am trying to have it where (as of now) You press E and you change from island 1, to island 2. This is the code for the teleporting I currently have:
using UnityEngine;
using System.Collections;
public class TeleportMe : MonoBehaviour {
public Transform transforming;
// Update is called once per frame
void Update () {
//if(transforming.networkView.isMine) {
if (Input.GetKey (KeyCode.E) ){
Teleport ("2");
}
/*if(transform.GetComponent<CharacterController>().isGrounded == false) {
agent.enabled = false;
} else {
agent.enabled = true;
}*/
// }
}
void Teleport (string place) {
if(transforming.networkView.isMine) {
var plobj = GameObject.Find("/CharacterRelated/SpawnMarkers/"+place);
var agent = transforming.GetComponent<NavMeshAgent>();
agent.Stop ();
agent.ResetPath();
agent.enabled = false;
transforming.position = plobj.transform.position;
agent.enabled = true;
} else {
var plobj = GameObject.Find("/CharacterRelated/SpawnMarkers/"+place);
transforming.position = plobj.transform.position;
}
}
}
It works. The character moves. The problem is, is any other client/server watches you do this, It still believes you are on the other island. (One navmesh total though). But when the character walks, he flashes between the two locations.
basically The client(lets call him client 1) (who teleported) sees he successfully teleported.
The other client/server sees he did not. But when client 1 walks, it updates the transform position so he flashes between each location. How do i fix this?