error C2664: 'void
ConstructorHelpers::ValidateObject(UObject
*,const FString &,const TCHAR *)': cannot convert argument 1 from
'UStaticMesh *' to 'UObject *'
Line 109 in ConstructorHelpers.h: ValidateObject( Object, PathName, ObjectToFind );
The code in the constructor:
static ConstructorHelpers::FObjectFinder<UStaticMesh>meshAsset(TEXT("/Game/Meshes/SM_MinePickaxeB_01")); // <<< error for this line
StaticMeshComp->SetStaticMesh(meshAsset.Object);
I also tried my own function but that one gave the exact same error:
I cleaned the project AGAAAAAAAAAAAIN and now it compiles. Of course without any mesh assigned but hell, at least the project compiles. What is going on…
Apparently the compiler expects an UObject. UStaticMesh* is an object but… Pressing F12 on UStaticMesh* brings me to a forward declaration in Engine.h. So the compiler does not (yet) know that this in fact is an UObject.
Solution (yes it’s very simple):
#include "Engine/StaticMesh.h"
Of course the question still remains: Why did it compile prior to adding this nonsense line:
WeaponAnimType = EWeaponAnimType::Pistol; // TODO: Use pickaxe animation.
And why does it also not compile anymore when I hit ctrl+z until it reverts back to the original state? It still does not compile even though the code is now EXACTLY THE SAME as when it used to compile. BUT when I use SourceControl to revert the exact same change, then it compiles. So even though I found the problem and solved it, there is something much more nasty going on somewhere (and I still suspect a UE4-related bug). If someone figures this out some day, please let me know!
I spent a day trying to solve this problem. Error message is not informative and Visual Studio doesn’t warn me about adding that header file. Now it works, thank you!