Dot Product Problems

void UBTSteeringService::TickNode(UBehaviorTreeComponent &OwnerComp, uint8* NodeMemory, float DeltaSeconds)

//Set up some vectors for storage.
FVector AIForwards = OwnerComp.GetOwner()->GetActorForwardVector();

	//Calculate the vector from the AI to the Player and normalize it.
	FVector AIToVector = (PlayerPawn->GetActorLocation() - OwnerComp.GetOwner()->GetActorLocation());

	//Update the steering value.
	UpdateSteeringValue(OwnerComp, AIForwards, AIToVector);

	//Update the throttle value.
	UpdateThrottleValue(OwnerComp, AIForwards, AIToVector);

void UBTSteeringService::UpdateThrottleValue(UBehaviorTreeComponent & OwnerComp, FVector AIForwards, FVector AIToPlayer)
	//Get the angle between the AI's forward vector and the vector from the Ai to the Player.
	float Angle = FMath::Acos((AIForwards.Normalize() | AIToPlayer.Normalize()) / (AIForwards.Dist * AIToPlayer.Dist));

My problem with the code above is the Dot Product Line ‘AIForwards.Normalize() | AIToPlayer.Normalize()’

I’ve included how I calculate these vectors in case my problem lies there.

VS17 throws Compiler error C2296 & 7 for this, stating that each operand has type ‘float (_cdecl*)(const FVector&, const FVector &)’

I have absolutely no idea why this doesn’t work. Many thanks to any views

First issue is that Dist is not a property but a function. Vector lengths are usually given in Unreal using the Size function like this:


The second issue is that there already exists a DotProduct function to do this for you so you don’t need to worry about implementing the function yourself.

float Angle = FMath::Acos(FVector::DotProduct(AIForwards, AIToPlayer));