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());
AIToVector.Normalize();
//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