I am trying to develop an MMORPG in Unity3d 2018 for Macs and PCs. When completed it will give a player a range of worlds to play on and explore so switching between them is an important mechanic. Through research, I think I have determined that switching users between MMO rooms and then loading that room's corresponding scene is the best way to approach this.
I have been having problems with the LeaveRoomRequests and getting the player to actually leave the room they are currently in. What I am trying to do is have the user click a UI button which will have them leave the room and then join the new one. Unity doesn't give me any errors when the function with the LeaveRoomRequest is run, but when I try to join a new MMO room it won't let me enter it and the server still shows that I am in the old room. The server doesn't seem to be showing any errors or responses to this request either.
To try and learn how to build an MMO like this using smartfox, I started with modifying the MMO demo project by adding the button that would switch the user's room and scene. This was when I first encountered the issue. After being unable to find a solution, I figured that something already in the project might be causing some sort of bug that was stopping the LeaveRoomRequest from working and decided that I should try and create a new project from scratch to solve the issue. Using the tutorial series from GenesisRage on youtube, I have gotten to the point where I can successfully connect, join the zone, and join the first MMO room. The series does not show me how to switch rooms so I used the documentation to recreate the switch room button I had been trying in the demo project (without the scene switch as I have not yet gotten that far into the project yet), but the problem still persisted. Any input someone might have as to how to fix this issue or possibly a better method for switching between worlds would be much appreciated. Thank you!
Screenshots:
https://drive.google.com/file/d/1B1Cy2K ... sp=sharing
Code:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
public class ButtonRoomSwitch : MonoBehaviour {
//Make sure to attach these Buttons in the Inspector
public Button m_YourFirstButton;
SmartFox sfs;
void Start()
{
sfs = new SmartFox();
sfs.ThreadSafeMode = true;
//Calls the TaskOnClick/TaskWithParameters/ButtonClicked method when you click the Button
m_YourFirstButton.onClick.AddListener(TaskOnClick);
}
void Update () {
sfs.ProcessEvents();
}
void TaskOnClick() {
sfs.Send(new LeaveRoomRequest());
Debug.Log("Room Left");
}
}