Hi. I’m very new to C++ and while following the First Person Shooter tutorial on unrealengine.com, I’ve come across this line in the file FPSProjectile.cpp:
CollisionComponent->OnComponentHit.AddDynamic(this, &AFPSProjectile::OnHit);
which throws the following error message:
C:\Users\CurrentUser\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSProjectile.cpp(15): error C2664: ‘void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UPrimitiveComponent *,AActor *,UPrimitiveComponent *,FVector,const FHitResult &>::__Internal_AddDynamic<AFPSProjectile>(UserClass ,void (__cdecl AFPSProjectile:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent ,FVector,const FHitResult &),FName)': cannot convert argument 2 from 'void (__cdecl AFPSProjectile:: )(AActor *,UPrimitiveComponent ,FVector,const FHitResult &)’ to 'void (__cdecl AFPSProjectile:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,FVector,const FHitResult &)’
with
UserClass=AFPSProjectile
]
C:\Users\CurrentUser\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSProjectile.cpp(15): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I’ve checked and double-checked and I’m sure I have reproduced all the code exactly as it is in the tutorial. Could someone explain that error message to me please?
I’m using Unreal Editor 4.13.1 and Visual Studio Community 2015.