Skip to content

AI tank cannot find the player's tank #22

@randomwangran

Description

@randomwangran

https://github.com/randomwangran/cpp/blob/988cab4f10322ef0052d0dc5c7fd6860006d86d0/Unreal/Section04/Source/BattleTank/TankAIController.cpp#L41-L45

This cause the issue of finding the wrong tank.

ATank* ATankAIController::GetPlayerTank() const
{
	auto PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
	if (!PlayerPawn) { return nullptr; } // Note the !, very important
	return Cast<ATank>(PlayerPawn);
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions