hey there, it seems i have an issue with the c++ code:
here is my code in the tankaiming component:
//if have aim solution:
bool hit;
hit = UGameplayStatics::SuggestProjectileVelocity(this, OutLaunchVelocity, StartLocation, WorldSpaceAim,
LaunchSpeed, false, 0, 0, ESuggestProjVelocityTraceOption::DoNotTrace);
if (hit ==true)
{
auto Time = GetWorld()->GetTimeSeconds();
UE_LOG(LogTemp, Warning, TEXT("%f tank can hit: %s"), Time, *GetOwner()->GetName());
}
else
{
auto Time = GetWorld()->GetTimeSeconds();
UE_LOG(LogTemp, Warning, TEXT("%f tank Cannot hit : %s"), Time, *GetOwner()->GetName());
}
my problem is that whenever it Cannot hit (looking at the sky), it wont run the else code, but wont run the if code either:
if i aim at the ground it logs:
LogTemp: Warning: 11.562568 tank can hit: Tank_BP_C_0 -----> this is the player tank
LogTemp: Warning: 11.562568 tank can hit: Tank_BP2_1632
LogTemp: Warning: 11.562568 tank can hit: Tank_BP3_6435
LogTemp: Warning: 11.562568 tank can hit: Tank_BP_757
if i aim at the sky it only gives the 3 ai tanks:
LogTemp: Warning: 11.929156 tank can hit:Tank_BP2_1632
LogTemp: Warning: 11.929156 tank can hit:Tank_BP3_6435
LogTemp: Warning: 11.929156 tank can hit:Tank_BP_757
why doesn’t it also show that the player tank Cannot hit? did i write the else code wrongly?