Anyone else need all default parmeters to use this ex-bugged function?

I noticed when I try to use SuggestProjectileVeolicty(), It requires all the defaults in place to not result in error. Could this be because of a sloppy fix for the bug that Ben Tristen reported?

I not sure it’s really a bug. When I explicitely the Default TraceOption (ESuggestProjVelocityTraceOption::TraceFullPath i think) , it would not behave correctly. I had to put DoNotTrace, or else the aiming was off.

I did try this again though, and I can’t see the bug happening anymore. The code changed a bit since that lecture so i’m not sure what’s the real cause of that “bug”, or wrong behavior.

The problem I get is that both visual studio and the compiler complain that I didnt enter the required arguments if I leave any defaults unpassed into the parameters. The function works okay but I have to fill in every parameter to use it

In example:

	bool bHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity
			(
				this,
				outLaunchVelocity,
				StartLocation,
				AimLocation,
				LaunchSpeed);

^ This will not compile.

Only something like this will compile:

TArray<AActor*> ActorIgnoreList;
ActorIgnoreList.Add(GetOwner());

	bool bHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity
		(
			this,
			outLaunchVelocity,
			StartLocation,
			AimLocation,
			LaunchSpeed,
			false,
			0.f,
			0,
			ESuggestProjVelocityTraceOption::DoNotTrace,
			FCollisionResponseParams::DefaultResponseParam,
			ActorIgnoreList,
			true);

^ All function parameters filled in

That’s weird. Why they put defaults if you have to provide the values!!?!
Between you and me, I don’t trust Defaults.
:grin:

lol yeah but at the least for something simple it would be nice not to have to pass every passable argument every time. Especially when ur a beginner trying to figure out how those needed arguments even work.

My suspicion is that the stubborn programmer that replied to Ben’s bug couldn’t fix it, or didnt/refused to investigate enough, and just forced people to fill in the defaults.

The Tim guy that replied to Ben’s bug tell’s people off on the answer hub all the time; i’ve seen it before

also laura ridge is a corrupt lunatic; lols

What was your compilation error? also DoNotTrace is not the default value, TraceFullPath is.

This is the issue with Default Parameters in C++:


Goto the heading “Multiple default parameters”. It states the following:

Note that it is impossible to supply an argument for parameter z without also supplying arguments for parameters x and y. This is because C++ does not support a function call syntax such as printValues(,3). This has two major consequences:

  1. All default parameters must be the rightmost parameters. The following is not allowed:

1 void printValue(int x=10, int y); // not allowed

  1. If more than one default parameter exists, the leftmost default parameter should be the one most likely to be explicitly set by the user.

Number 2 is where the key is. All parameters up to the TraceOption must be set to be able to change the TraceOption from TraceFullPath to DoNotTrace

But that was not the issue with the default parameters, it was Ben’s explicit mistake.
When he deleted provided values for collision radius and gravity the trace option parameter was implicitly converted to bool later

Privacy & Terms