Error C2664: Cannot convert argument 1 from 'const TWeakObjectPtr'

It seems to me the problem is you are calling up your PawnCanBeSeen function using a FConstPawnIterator which contains (as the name implies) a constant object pointer. However, your function, as it is currently declared, requires it be fed a non-constant object pointer, which means the compiler assumes that the function is allowed to modify the pointed-to object (even if it doesn’t actually do so).

This means your function isn’t allowed to be fed a constant object pointer, like those contained by the FConstPawnIterator, because constant objects can’t be modified, but the compiler assumes your function does modify this parameter (in this case, the pointed-to object).

So try changing your PawnCanBeSeen function declaration to make its parameter constant, like so:

UFUNCTION(BlueprintCallable, Category = "Behavior")
bool PawnCanBeSeen(const APawn* target);

Since you aren’t modifying the pointed-to object within this function anyway, it should be fine to make this change. (Actually, I would dare to say this reflects good coding practice.) This will tell the compiler that your function does not modify the pointed-to target object in any way, and allow the function to work the way you need it to.

Or at least I think.

Hopefully that does it and everything compiles fine after.