So I am trying to refactor the Player Controller and the AI Controller to talk to the Aiming Component, but in the TankAIController my GetComponentByClass() statement is not working.
Here is the function were I am defining the AimingComponent variable:
void ATankAIController::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
auto PlayerTank = Cast<ATank>(GetWorld()->GetFirstPlayerController()->GetPawn());
auto AimComponent = GetControlledTank()->GetControlledTank()->GetComponentByClass<UTankAimingComponent>();
if (PlayerTank)
{
MoveToActor(PlayerTank, AcceptanceRadius);
AimComponent.AimAt(PlayerTank->GetActorLocation());
ControlledTank->Fire(); // TODO Limit fire rate
}
}
In Unreal it gives me an error saying: Error D:\GitHub\01_BattleTank\BattleTank\Source\BattleTank\Private\TankAIController.cpp(23) : error C2275: ‘UTankAimingComponent’: illegal use of this type as an expression
Any suggestions as to what this might mean? I have included the TankAimingComponent.h file in the top of the cpp.