TankAIController.cpp: error 'ATank::AimAt': function does not take 1 arguments

TankAIController.cpp : error ‘ATank::AimAt’: function does not take 1 arguments
TankPlayerController.cpp : error ‘ATank::AimAt’: function does not take 1 arguments

So I got these errors after I fixed
a TankAimingComponent.cpp one
(UE_LOG(LogTemp, Warning, TEXT("Firing at %f cm"), launchSpeed);
why does launchSpeed not use a “contents-at” *launchSpeed ?
when we use %s String we have to use *string)

Ok, in the
TankAIController.cpp I ended up using a hacky (I think so) bit of code to reference(?) the pointed-to Tank’s own member variable since it requires 2 parameters

void ATankAIController::Tick(float deltaSeconds)
{
	Super::Tick(deltaSeconds);
	if (GetControlledTank())
	{
		GetControlledTank()->AimAt(GetPlayerTank()->GetActorLocation(), GetControlledTank()->launchSpeed);
	}	
}

Ben didn’t seem to get any errors so maybe my code deviated a bit between all those videos
Does anyone know if there’s a way to make the 2nd parameter optional, since the ATank class method we are calling already knows this information?
(something similar to when we called GetWorld()->LineTraceSingleByChannel() we left last 2 parameters off)

On another note; does anyone feel the code is getting complex now, some functions seem to cascade down multiple layers and often I find myself having to skim through classes again wondering where did this come from, who called this etc!
Some of it is probably tied up to the fact that we’re usefully talking to Blueprints which adds a lot of new code.

Thanks for reading

.

UPDATE: Having browsed Ben’s repository for the first time (intimidating but very cool)
I understand now, I conflated the AimAt() in the Tank.h, Tank.cpp with the TankAimingComponent.h, TankAimingComponent.cpp only the latter class’ AimAt() needed to received information it didn’t already know, the Tank already gets it (launchSpeed) and now so do I !

(TankAIController.cpp, TankPlayerController.cpp calling AimAt() doesn’t inherently know launchSpeed either since this mechanics part is delegated (?) to our ‘ATank’ (in which it might delegate the mechanical turning of turret further !))

1 Like

I haven’t noticed that too, thank you for this tip!

Privacy & Terms