How does it act like a tick?

how does aimat() call everytime we aim? what im saying is, how does HitLocation update. Im not sure how it fully woks.

The controller classes (AI/PlayerController) are the ones that call the AimAt() function on their tanks which happens every tick.

how does the controller call it every tick?

It calls it in it’s tick function.

// Called every frame
void ATankAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (GetPlayerTank())
	{
		// TODO Move towards the player
		
		// Aim towards the player
		GetControlledTank()->AimAt(GetPlayerTank()->GetActorLocation());

		// Fire if ready
	}
}
void ATankPlayerController::Tick(float DeltaTime)
{
	Super::Tick( DeltaTime );
	AimTowardsCrosshair();
}

void ATankPlayerController::AimTowardsCrosshair()
{
	if (!GetControlledTank()) { return; }

	FVector HitLocation; // Out parameter
	if (GetSightRayHitLocation(HitLocation)) // Has "side-effect", is going to line trace
	{
		GetControlledTank()->AimAt(HitLocation);
	}
}

oops. sorry for being stupid. I took a break between making this and forgot there was a tick at the top the page that we made. thanks anyway.

Privacy & Terms