How to tell which function parameters are optional?

I spent a lot of time setting up all the parameters for the SuggestProjectileVelocity function only to find that the course omits using the last three params. Here’s what the Unreal docs for the method look like:

static bool SuggestProjectileVelocity
(
    const UObject * WorldContextObject,
    FVector & TossVelocity,
    FVector StartLocation,
    FVector EndLocation,
    float TossSpeed,
    bool bHighArc,
    float CollisionRadius,
    float OverrideGravityZ,
    ESuggestProjVelocityTraceOption::Type TraceOption,
    const FCollisionResponseParams & ResponseParam,
    const TArray< AActor * > & ActorsToIgnore,
    bool bDrawDebug
)

Is there some way to tell from the docs that ResponseParam, ActorsToIgnore, and bDrawDebug were optional?

Check the declaration (also comes up in IntelliSense) default arguments are provided with =
i.e.

int square(int n = 3)
{
    return n * n;
}
int main()
{
    int val = square(); //square(3)
}

Arguments can’t be skipped so default arguments can only go on the end of a parameter list.

1 Like

Thanks! This was good motivation to finally fix my broken Intellisense. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms