Editor instantly crashing

I’m trying to understand c++.
I have PlayerController(Blueprint), Interface(c++) and Character(c++).
When right mouse button down PlayerController storing mouse location and sending to character with interface.
I think there is no problem here.
I tested with this code and its working.

“GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::, TEXT(“Working!”));”

But when i use this code(MoveToLocation) and when right mouse button down editor instantly crushing. And there is no compile error in this code.

In the .h:

virtual void MoveCharacter_Implementation(const FVector Location, FName PlayerTag) override;
AAIController* heroMasterAI;

In the .cpp:

void AHero_Monk::MoveCharacter_Implementation(const FVector Location, FName PlayerTag)

{

  GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::, TEXT("Working!"));
	heroMasterAI->MoveToLocation(Location, -1.0f, true, true, true, true, NULL, true);

}

I’m doing something wrong and i don’t know what is wrong

Hello,

one basic thing is checking if your GEngine ist initialised correct:

you should always use :

  if (GEngine)
  {		
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::, TEXT("Working!"));	
  }

It doesn’t solve my problem. :frowning:

Hello ,

Have you tried commenting out these lines of code to see if they are what is causing the crash?

when i comment this “MoveToLocation” line there is no error or crash and I’ve tried other lines.
Maybe i need to set ai controller but i don’t know how i set this. I looked shooter game. in shooter game there is line in ShooterBot.cpp file "#include “Bots/ShooterAIController.h” in constructor “AIControllerClass = AShooterAIController::StaticClass();” but i can’t do similar like this in my character class. I’m keep getting this error “Hero_Master_AI” error C2653 is not a class or namespace name.
I tried blueprint to blueprint communication with interface(c++) and there is no problem but maybe c++ can’t get this value “const FVector Location” and i don’t know how i print string FVector value for testing.

You can find information here for printing out an FVector for testing purposes:

As far as setting your AIController, does the AI that you intended to control with this controller exist in the level before runtime? If so, you can select it from the World Outliner and set its AIController in the details panel.

there is no problem “const FVector Location” variable
I tested with “print(Location.ToString());”
What is proper use of “MoveToLocation” in c++ ?

Have you checked if your AAIController* heroMasterAI points to an existing object?
Maybe you didnt initialise the object and the pointer references to nothing,
this would lead to an error.

Hello ,

Have you had a chance to try 's suggestion of checking the pointer? This would definitely cause a crash if it is indeed the problem.

We haven’t heard from you in a while, . Are you still experiencing this issue? In the meantime, I’ll be marking this as resolved for tracking purposes. Please let me know if you require anymore assistance and the question will reopen.

Have a nice day!