Hey there, im trying to have some debug info attached on to the player character. I am using the TopDown code approach from the prebuilt projects, so basically its a guy that you control running around.
I post this here as i could not find a real example of how to use the method, so maybe this helps other people as well. This is what i am using.
void DrawDebugString
(
const UWorld * InWorld,
FVector const & TextLocation,
const FString & Text,
class AActor * TestBaseActor,
FColor const & TextColor,
float Duration
)
I call it in the Tick method of the controller. so what i do is, inside PlayerTick() of the playercontroller.cpp i call:
FString bla = Fstring("dkldkal");
FColor red = FColor::Red;
DrawDebugString
(
getWorld(), // i want it to be inside the current level
getPawn()->getActorLocation(), // i want it to be where my character is
bla, // thats the text i want to display
getPawn(), // i dont really know what to put here, but i guess it should be my character right ?
red,
-1.0 // for now display it all the time
);
i would like to have the string only once and floating over the head of my char.
So what happens is it appears, and it appears multiple times , which i expected as every string just stays in the wold, as of time duration set to -1.0f.
What is really weird is the position: it seems to be way of off the character, but not only that, as i move, the position accelerates, relative to the character. This leads to the text flying in and out of the viewscreen.
i can understand its offset form the char, as i have wrong location, because of getActorLocation() giving location of root of actor, but that weird acceleration confuses me.
what is my mistake ? where should i call that DrawDebugString message anyway ? i cannot find game loop function in unreal engine, so i guess the PlayerTick servers as that , as thats where i am calling it .
How can i make this message only appear once ?
thank you for any helpful answers !!