Showing debug visuals

Hey guys

I’m trying to display a debug visual from something that isn’t in the game world or a UE object. I started by making my own UGameViewportClient class based on an old Ramatorial but it’s not really working.

  1. What’s the best way to display debug visuals? Just draw them to the hud?

  2. What’d I do wrong, anyway?

My code actually lives in a plugin, which we’ll call MyPlugin. I tried lots of variations of this:




How would I properly route that to the right class? I was getting a “viewport is null” crash on startup with anything I tried.

Can’t figure out what you did wrong right now, but I recommend just drawing Debug stuff to the HUD or in-world.

Unreal has a cool (DrawDebugHelpers.h) library that let’s you draw lines, points, curves, shapes etc on screen in different colours and whatnot. Useful for many things!

Should be


Note that your module name isn’t necessarily the same as your plugin name, though it probably is. The module name is whatever precedes the .Build.cs of your build script filename. Note also that you should drop the ‘U’ prefix from ViewportClassName.

That said, if you’re just looking to draw 2D stuff overlaid on the screen, then you should absolutely just use the HUD as advised. Much more straightforward.
If you want to draw 3D stuff, you’ll need to look at creating primitive components. There are a bunch of examples in the engine code, EQSRenderingComponent.h for example.

Yup, the HUD is doing what I need for now. I do still need to override the viewport eventually though, so thank you for explaining that. :slight_smile: Is there a way to change GameViewportClientClassName without editing the ini file?

And last question: I can’t find a lot of info on writing out raw colour data to a Texture2D object. I checked out DrawDebugHelpers.h and it’s neat, but there’s no option to write pixel colour data to it. This is just for debugging so it doesn’t need to be fast, but I need a way to see that output in-editor if possible.

Edit: Rama already did it, naturally. He pastes an example here:!&p=359116

The answer to 9 out of 10 problems is the Rama Thread.