Strange Behavior After Adding Params

I’m having issues with SuggestProjectileVelocity after adding all parameters. I have lot’s of “Solution Not Found” so I turned on debugging lines and it appears that the AI is unable to find a successful path I now know this is because the static mesh is blocking the function from calculating to the final point which is inside the tanks static mesh.

So I added the player pawn to the TArray<AActor*> ActorIgnoreList; and now that works, the ai controllers can get a path to the player. You can see in the images that the Ai Controlled Tanks Are now able to calculate a path to the player controlled tank. Oops just realized the reason I am not getting a no path found log message is that I am not running the calculation if no hit result is found in the playercontroller. I’m going to attach the images and such anyway though.

void UTankAimingComponent::AimAt(FVector WorldSpaceAim, float LaunchSpeed)
{
if(!Barrel){ return; }
auto *PawnOwner = GetOwner();
FVector OutLaunchVelocity;
FVector StartLocation = Barrel->GetSocketLocation(FName("Muzzle"));
FCollisionResponseParams ResponseParam;
TArray<AActor*> ActorIgnoreList;
ActorIgnoreList.Add(GetOwner());
ActorIgnoreList.Add(GetWorld()->GetFirstPlayerController()->GetPawn());

bool BHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity
(
 this,
 OutLaunchVelocity,
 StartLocation,
 WorldSpaceAim,
 LaunchSpeed,
 false,
 0.0f,
 0.0f,
 ESuggestProjVelocityTraceOption::TraceFullPath,
 FCollisionResponseParams::DefaultResponseParam,
 ActorIgnoreList,
 true
 );

if(BHaveAimSolution)
{
    
    auto AimDirection = OutLaunchVelocity.GetSafeNormal();
    //MoveBarrel
    MoveBarrelTowards(AimDirection);
    auto Time = GetWorld()->GetTimeSeconds();
    
    UE_LOG(LogTemp, Warning, TEXT("%f Solution Found for: %s"), Time, *GetOwner()->GetName())
    // Convert Aim Direction To Rotator That We Can you To Rotate and Elevate Barrel
}
else
{
    auto Time = GetWorld()->GetTimeSeconds();
    UE_LOG(LogTemp, Error, TEXT("%f Solution Not Found: %s"), Time, *GetOwner()->GetName())
}

}

You need to set the ESuggestProjVelocityTraceOption::DoNotTrace, not TraceFullPath

As I’ve also seen in your uploaded picture, debug lines start from the center of turret, but not the “projectile” socket on muzzle. Why is that? May this be causing any problem?

Privacy & Terms