The lack of ability to debug server code is a major issue when developing anything MP-related.
Description
Details
- Severity
- Minor
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Operating System Version
- Windows 11 x64 - Microsoft Windows [Version 10.0.22000.675]
- Category
- General
How to replicate:
Create any script that will run on server and client.
Wrap a print statement with if(Replication.IsServer())
Place a breakpoint inside the if block
Use the debug menu in the script editor to check "Debug Server"
Goto the world editor and click the Play button dropdown and select "Server localhost" or "Server localhost + PeerTool"
Click Play
Notice that you will never hit the server breakpoint, however, you will see the server print the message which means the if block is running.
If you instead debug the client, you will see that breakpoints do work, however, the client correctly jumps over the if(Replication.IsServer()) check
Expected Behaviour:
When selecting Debug Server, you should be able to breakpoint server code.
When using "Server localhost" or "Server localhost + PeerTool" you should be able to swap between debugging the client and server during runtime via the Debug menu.
Workaround:
(this is terrible, I know)
Somewhere in the server code, cause an exception to occur (calling a function on a null class instance)
Do the above process, but close the script editor before running the game in the World Editor.
This will cause a popup to occur saying that an exception occurred. If you press the Debug button, the script editor will open and you will
be correctly debugging the server code. Just skip over the exception to continue debugging.