/// <summary> /// Updates another player's location in the AR world. /// </summary> /// <param name="username">The username of the player to update.</param> /// <param name="latitude">The new latitude location of the player.</param> /// <param name="posY">The Y coordinate of the player's new position.</param> /// <param name="longitude">The new longitude location of the player.</param> public void UpdatePlayerItem(string username, double latitude, double posY, double longitude, float heading) { // Check if username already exists; create/add it if new if (!PlayerItems.ContainsKey(username)) { GameObject playerGO = Instantiate(TeleportalAr.Shared._PlayerItem); XRPlayerItem playerXRItemComponent = playerGO.GetComponent <XRPlayerItem>(); playerXRItemComponent.ChangeTitle(username); // set floating title text Items.Add(username, playerXRItemComponent); PlayerItems.Add(username, playerXRItemComponent); } // Temporary variable for XRPlayerItem reference XRPlayerItem item = new XRPlayerItem(); // If this XRItem still exists... if (PlayerItems.TryGetValue(username, out item)) { // Update username / item ID item.SetId(username); // Update position item.SetLocation(latitude, posY, longitude); // Update rotation item.SetRotation(heading, 0); // Reposition player item to relative item.Reposition(); } else { print("Cannot update player: " + username + " does not exist"); } }
void Start() { // this.mixer = (AudioMixerGroup) GameObject.Find("AudioMixerControl"); this.audio = this.gameObject.GetComponent <AudioSource>(); this.XRI = this.gameObject.transform.parent.gameObject.GetComponent <XRPlayerItem>(); this.isSelf = (this.XRI == null); if (this.isSelf) { this.transformYEET = TeleportalPlayer.Current.gameObject.transform; } else { this.transformYEET = this.gameObject.transform.parent; // XR Player Item } StartCoroutine(this.sendUpdatesC()); }