Download

C++ Custom Behaviour Tree Service not getting called

I have added the c++ service to my Behaviour tree and it never gets called.

I have C++ BT Tasks that get called just fine.
I have blueprint custom BT services that get called just fine.
But c++ BT services never get called, as you can see i have log message in it and also added break points that never get hit.

Any help much appreciated

I am using UE5

Everything i am doing with Behaviour Tree in BP and C++ works just fine except C++ BT Services
As mentioned BP Services work too.

UCLASS()
class UBTS_SetupNpcChase : public UBTService_BlackboardBase
{
	GENERATED_BODY()

public:
	//UBTS_SetupNpcChase(const FObjectInitializer& ObjectInitializer);
	UBTS_SetupNpcChase();

	//UFUNCTION(BlueprintCallable)
	void OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
	

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "NPC Data", meta = (AllowPrivateAccess = "true"))
		FBlackboardKeySelector mvo_PlayerCharKey;
};

UBTS_SetupNpcChase::UBTS_SetupNpcChase()
{
	//verify(false);
	bNotifyBecomeRelevant = true;
	bNotifyTick = true;
	bNotifyCeaseRelevant = true;
	bNotifyOnSearch = true;

}
void UBTS_SetupNpcChase::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
	

	Super::OnBecomeRelevant(OwnerComp, NodeMemory);

	M_LOG(g_AppLog, Display, true, "UBTS_SetupNpcChase::OnBecomeRelevant");
	
	AAIController* pAiCtrl = Cast<AAIController>(OwnerComp.GetAIOwner());
	ANpcCharacterBase* pNpcChar = Cast<ANpcCharacterBase>(pAiCtrl->GetCharacter());
	UBlackboardComponent* pBlackBoardComp = OwnerComp.GetBlackboardComponent();


	


	ACharacter* pPlayerChar = Cast<ACharacter>(pBlackBoardComp->GetValueAsObject(mvo_PlayerCharKey.SelectedKeyName));
	verifyf(pPlayerChar != nullptr, TEXT("Invalid Player pointer"));


	FRotator lc_lookRotation = UKismetMathLibrary::FindLookAtRotation(
		pNpcChar->GetActorLocation(),
		pPlayerChar->GetActorLocation()
	);

	pNpcChar->SetActorRotation(lc_lookRotation.Quaternion());

}

Just added the Behaviour tree that uses the service.
Again my problem is that the service never runs
cheers

Think i found the problem

I had BTS BPs BTTs , some with similar names And even C++ custom tasks and Services ,

Basically i was selecting the wrong Service, cause the names are similar and Unreal Seems to mess with what you name files a lot , for example it adds its own characters and often removes underscore .

The point is in message to unreal

  1. Please allow developers to choose their own naming convention without adding A’s and U’s and etc to what we name stuff.

  2. Please if i add underscore to a name, please show that underscore wherever the name is being displayed, cause with the BP’s BTTS. BTS’s along without the CPP’s we going to need underscore to name files, so would be best to add the underscore in menus without changing the name in anyway.

Having to get used to the naming issues with unreal is part of the learning curve, its simple soltion to just name stuff excatly what people put in th dialogue box at creation, like with Visual Studio etc

Imagine how confusing it would be if Visual Studio has a convention of removing underscore from names and often adding extra characters to names of files. That would get very confusing quite quickly.

Simple solution i create file called ==== MyName_Is_DontChange

i would expect not to see a file called ==== AMyName_IsDontChnage

Now i need to go find a naming convention that cant lead to confusion given the name you type is not what you endup with in Unreal. Its Unreal, just think if other tools did this too.

All files you create are given the names you created them with. The editor, unless you’ve installed some sort of plugin that does this, will not change the names of things for you. So, much more likely, that you mistyped the names of things. There are recommended naming conventions for assets, but there is zero enforcement of that.

When you create C++ classes, you must follow the naming conventions. It doesn’t care what your files are called, or how you structure that, but your classes that derive from UObject must start with a U, your classes that derive from an Actor must start with A, your Enums must start with E, and so on and so forth.

Thats my point, this forces programmers who already have thier own naming convention to use Unreal naming convention , and this adds to the learning curve.

People who have been writing code for decades suddenly have to get used to unreal coding style in detail. And thats not a selling point is all am saying.

Windows API is more vast than unreal, but windows does not force you to use thier naming conventions, by adding extra characters to names off types when you create them.

Also C++ files dont appear as the same name in all windows of the editor, some letters are dropped , i have C_ which i add to c++ types so i can tell them apart from BP’s . In some menus you see the C_ in other menus it does not appear.

This enforced naming convention and adding characters to types you create, just means unnecessary confusion. Its simple enough to just always show the name user call their stuff, without messing with it in anyway.

I don’t personally know of any other API or tool that forces users to use a certain coding convention. This is not normal, and adds to the learning curve and confusion.

i just had to restart a project renaming everything very defensively to avoid confusion as project files multiply cause the names shown for types in menus is not exactly what the source file is called.
This is a recipe for mistakes.

There are organisation who have their own strict coding conventions that will have a problem using Unreal engine.

Basically all the c++ types have different name in editor , that’s recipe for disaster on big project.

Solution simple when someone type in name to create stuff, dont change it., and let people use naming convention they are used to.

Also in the editor menus its often the case that underscore in names is often replaced by space , to add to the confusion.

This debacle with naming , and inconsistency of type names in editor menus is on the same level as the Ue4 deplorable documention , whichi is a joke in its on right.

Its a great product dont get me wrong , but you get the impression unreal delivery lacks professionalism, sometimes it feels like a product developed in someone garage. A genius no doubt , but no professional delivery .

How many API or tools do you know that enforce naming convention, by messing with names you choose when you create types. Its a recipe for disaster.