How To Debug my Game in Visual Studio? (solved)

I would like to be able to put breakpoints in Visual Studio and debug my code, but when I tried it all it did was open the editor?
Visual Studio started tracking things like CPU and Memory, and it looked like it was working, but when I started a Standalone game in the editor nothing happened when the code hit the breakpoint I placed.

Can I get it to actually break at the breakpoint and do things like halt the code so I can check variables and such?
(like how breakpoints work in the editor) Or does Debug just not do what I think it does?

Do you have UE4 visual studio extension installed?
Is visual studio in ue4 debug mode?
Did you launch the editor by building and running from visual studio?

Hi Erdrik

Once you add a breakpoint in visual studio it will pause your game, and from here if you put the mouse over some text, it will show you the variables and what is holding, also from here, you can debug line by line and see how your visual studio jumps from if to for to while to etc,

Check the blue arrows in the top bar, you can jump line by line

EDIT: Breakpoints does not work in standalone, the standalone is consider an external application, you have to link visual studio

“Do you have UE4 visual studio extension installed?”

I did not. I didn’t even know it existed. I have now installed it.

“Is visual studio in ue4 debug mode?”

Probably not? I didn’t know there was a specific mode to set.
How would I do that?

“Did you launch the editor by building and running from visual studio?”

When I started the Debugging, VS claimed the project was out of date(even though it wasn’t) and asked me if I wanted to build.
I clicked yes, it built the project(the resulting output window said the project was up to date), then the editor loaded.
So technically yes? Unless there is a specific “load the editor from VS” button. Then no.

EDIT:
@ZkarmaKun
Ah. It appears to work fine in PIE. Thank you.

@Erdrik

Yes!, sorry, you have to link visual studio to standalone, check this wiki will show how to debug in package, https://wiki.unrealengine.com/Debugg…Packaged_Games
I know is possible to standalone, but I have no idea

Unclear from your first post if you want to debug a cooked packaged build or just running your game from the editor.

Easiest:
You can set a breakpoint and then hit play in VS with the DevelopmentEditor target selected… Once in editor you are debugging, you can just play in the editor and your breakpoints will work.

Harder: To debug and set breakpoints in engine code, you will need to have the debug symbols for the engine installed and run a DebugEditor target .

Harder still : To debug and test a packaged cooked game: Run your package game (which must have been built with symbols) then use VS to attach to the process. A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

I updated my project to 4.17.2, and Visual Studio to 2017.
Now when I try to debug in VS, it says it is unable to start the editor and that MSVSMON failed to start.
I also tried directly attaching to the Editor’s process but that also failed.

I get the following warning after a successful compile:
warning MSB4011: “F:\Work\VSC17\VSC\Common7\IDE\VC\VCTargets\Microsoft.Makefile.props” cannot be imported again. It was already imported at “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.cpp.props (31,3)”. This is most likely a build authoring error. This subsequent import will be ignored. [F:\Documents\Unreal Projects\OrtCloud4\Intermediate\ProjectFiles\OrtCloud4.vcxproj]

The warning does not seem to impact the project or editor as my project still compiles with “1 success” in VS2017, and can be loaded into and compiled in the 4.17.2 version of the editor successfully.
In VS my project and the engine project both have the following appended to their displayed names(in the solution explorer):
(Visual Studio 2015)

I tried repairing the VS2017 install but there was no change.
How can I get Debugging to work again?
(also how do I get rid of that warning? could it be affecting the debugger?)

EDIT:
After reading around I realized I didn’t move UE4.natvis into my VS folder.
After doing so the VS Debugger started working.