Confused about function parameter

I am using LineTraceSingleByObjectType() and am confused about how one of the parameters works.

According to the documentation:


[bool](https://docs.unrealengine.com/en-US/API/Runtime/LiveLinkInterface/bool/index.html) LineTraceSingleByObjectType
(
    struct [FHitResult](https://docs.unrealengine.com/en-US/API/Runtime/Engine/Engine/FHitResult/index.html) & OutHit,
    const [FVector](https://docs.unrealengine.com/en-US/API/Runtime/Core/Math/FVector/index.html) & Start,
    const [FVector](https://docs.unrealengine.com/en-US/API/Runtime/Core/Math/FVector/index.html) & End,
    const [FCollisionObjectQueryParams](https://docs.unrealengine.com/en-US/API/Runtime/Engine/FCollisionObjectQueryParams/index.html) & ObjectQueryParams,
    const [FCollisionQueryParams](https://docs.unrealengine.com/en-US/API/Runtime/Engine/FCollisionQueryParams/index.html) & Params
) const

Why is it that FHitResult, and Fvector parameters take an argument that I previously declared e.g.


FHitResult hit;

But FCollisionObjectQueryParams appears to take as an argument itself with a defined constructor:


FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody)

I have never seen this in code before. From what I am reading, FCollisionObjectQueryParams is a structure… how is it possible to put a struct in as the argument. Where is the object?

Thanks!

In the first case, you have a function that takes an argument FHitResult as an output parameter, in other words, it takes the structure you declared and writes data to it that you can then use. In the second case, the structure is initialized with a certain immediately specified UEnum parameter.
Otherwise it would look like this:



[FCollisionObjectQueryParams](https://docs.unrealengine.com/en-US/API/Runtime/Engine/FCollisionObjectQueryParams/__ctor/2/index.html) coqp;
coqp.QueryChannel = ECollisionChannel::ECC_PhysicsBody;


Just the first option is more compact.

Ok thanks!! The longer version that you wrote is what I am familiar with in code. I have never seen just a type (in this case type FCollisionObjectQuereyParams) used as an argument by itself to a function that takes that type parameter.

Like if I have a function that is defined to take an int you cannot type foo(int) as a valid argument. I guess what you are saying is… because of the enum parameter something magical is happening to initialize a value.

Nothing magical at all. An enum is basically a type wrapped around an int but the type itself is ECollisionChannel and the value is ECollisionChannel::ECC_PhysicsBody. It is like calling foo(1) or foo(2) not like calling foo(int). Maybe read up on enums and it will all make sense.

Thanks!!! That’s it. I have rarely seen enums

OHHHHH an enum holds a constant int