Debugging C++ code

How can I debug my C++ code, when using Visual Studio?

I’ve created a new projectile, based on the First Person C++ template, but I’m unsure of how to set breakpoints or debug.

Obviously I can’t just hit F5 from within Visual Studio, so what can I do with Rocket?

Open your solution in Visual Studio. Set the target to “Debug Editor” and you can absolutely hit F5. It’ll hit any breakpoints you set either before Rocket runs or while Rocket is running. You’ll have to hit the “Play In” button in Rocket though.

Worked like a charm! Thank you!

It creates an instance of Rocket which is only used for debugging. Once you stop debugging, it kills the instance.

Run debug from the target, either your game or editor.

Set breakpoints like normal in Visual Studio.

Oh I see now - just attach the debugger from visual studio to the process (rocket)

Works great!

Last question: I come from a JS background where you can just wrote console.log for all log expressions. How would undo it here? Cout << ?

You setup a Logger, the instructions are somewhere on here.

Here is a related post but not the exact one I remember that showed how to do it.
https://rocket.unrealengine.com/questions/3374/logging-actor-names.html

Just the answer I was looking for - thank you.

From the target?

One little observation: Breakpoints will not be triggered if you set your project to support CLR (general properties). At least in my 4.7.5 UE do not work

If you don’t need that you can just go to your solution configuration and set it to Debug Editor as pointed above. It works

What do you mean by “run debug from target”.

Why I saw varaible has been optimized ? I can not see the value