error C2664: Cannot convert argument 1 from 'const TWeakObjectPtr'
Hello everyone, I am a beginner in c ++ in eu4 and I am reading the book 'Mastering Unreal Engine 4' and I found a problem. When I write the AI code, at the time of compiling these errors appear: EnemyAIController.cpp(104): error C2664: 'bool AEnemyAIController::PawnCanBeSeen(APawn )': Cannot convert argument 1 from 'const TWeakObjectPtr' to 'APawn ' and EnemyAIController.cpp (43): error C2664: 'void UBlackboardComponent :: SetValueAsVector (const FName &, FVector)': Cannot convert argument 1 from 'int32' to 'const FName &'. Does anyone there know how to fix these errors? If you know please reply to this message. Thank you! CPP:
It seems to me the problem is you are calling up your
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
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
Or at least I think.
Hopefully that does it and everything compiles fine after.
Follow this question
Once you sign in you will be able to subscribe for any updates here