How do I display Debug Text from CharacterMovementComponent

I’m new to programming. It was pretty easy inside of Blue Prints but now I’m trying to look at what certain Vectors I being produced from my CharacterMovementComponent.cpp I have some custom stuff in there and things are not lining up so I would like to Draw the variable data to the screen just like the Print function in Blueprints does.

GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, FString::FromInt(x)); // x is the variable name

Though you want to display vectors right? Well you’ll want to use floats. So to use floats you’ll want to use this…

GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, FString::SanitizeFloat(x)); // x is the variable name you want to use.

The nice thing about vectors is you can separate the .X the .Y and the .Z :slight_smile:

Very cool and thanks. Is there a way to do the entire Vector (X,y,Z)? I guess additionally do you know how to append things together? It was nice in BP to just plop a Vector into the Variable and it would auto add the convert node, then I could just append a few things together to get one line of readout. So in my situation I’m trying to compare to Vectors so I know what’s going on in them, it would be nice to have them on one line of Debug with a space inbetween.

Yeah I’ve been doing alot of this :slight_smile: The Debug features seem less obvious from in the source. Most other functions are pretty straight forward - Take these types, do this, and return this.

GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Yellow, FString::SanitizeFloat(GetActorLocation().X) + FString::FString(" “) + FString::SanitizeFloat(GetActorLocation().Y) + FString::FString(” ") + FString::SanitizeFloat(GetActorLocation().Z));

As opposed to normal C and C++ where you simply use the << and >> operators (If you’re working with consoles and streams!) you only need to use the + symbol to append when using various UE4 methods.

This should do the trick, pal.

If you already build something for Blueprint that worked and you want to go to c++ i recommend to rightclick on nodes and “go to definition”… then you can see how the guys from epic are doing it…

ToString() that vector!