I’m trying to create pickups that appear in the players hand when they walk into it, But no matter what i do I’m plagued by compiler errors at the moment I’m stuck on Error C2664, Here’s a snippet from my log and from my code:
Code:
#include “Wieldable.h”
#include “MinecraftUE4.h”
#include “MinecraftUE4Character.h”
// Sets default values
AWieldable::AWieldable()
{
PrimaryActorTick.bCanEverTick = true;
WieldableMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WieldableMesh"));
PickupTrigger = CreateDefaultSubobject<UBoxComponent>(TEXT("PickupTrigger"));
PickupTrigger->bGenerateOverlapEvents = true;
PickupTrigger->OnComponentBeginOverlap.AddDynamic(this, &AWieldable::OnRadiusEnter);
PickupTrigger->AttachTo(WieldableMesh);
MaterialType = EMaterial::None;
ToolType = ETool::Unarmed;
}
// Called when the game starts or when spawned
void AWieldable::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AWieldable::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FRotator rotation = WieldableMesh->GetComponentRotation();
rotation.Yaw += 1.f;
WieldableMesh->SetRelativeRotation(rotation);
}
void AWieldable::OnRadiusEnter(AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
AMinecraftUE4Character* Character = Cast<AMinecraftUE4Character>(UGameplayStatics::GetPlayerCharacter(this, 0));
Character->FP_WieldedItem->SetSkeletalMesh(WieldableMesh->SkeletalMesh);
Character->MaterialType = MaterialType;
Character->ToolType = ToolType;
Destroy();
}
Log:
CompilerResultsLog: New page: Compilation - 20 Aug 2017 12:23:24
CompilerResultsLog: Info Compiling game modules for hot reload
CompilerResultsLog: Info Parsing headers for MinecraftUE4Editor
CompilerResultsLog: Info Running UnrealHeaderTool “C:\Users\George\Documents\Unreal Projects\MinecraftUE4\MinecraftUE4.uproject” “C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Intermediate\Build\Win64\MinecraftUE4Editor\Development\MinecraftUE4Editor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsA
sErrors -installed
CompilerResultsLog: Info Reflection code generated for MinecraftUE4Editor in 6.5941435 seconds
CompilerResultsLog: Info Performing 3 actions (4 in parallel)
CompilerResultsLog: Info Wieldable.cpp
CompilerResultsLog:Error: Error C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Source\MinecraftUE4\Wieldable.cpp(18) : error C2664: ‘void TBaseDynamicMulticastDelegate::__Internal_AddDynamic(UserClass ,void (__cdecl AWieldable:: )(UPr
imitiveComponent *,AActor *,UPrimitiveComponent ,int32,bool,const FHitResult &),FName)': cannot convert argument 2 from 'void (__cdecl AWieldable:: )(AActor *,UPrimitiveComponent ,int32,bool,const FHitResult &)’ to 'void (__cdecl AWieldable:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)’
CompilerResultsLog: Info with
CompilerResultsLog: Info [
CompilerResultsLog: Info UserClass=AWieldable
CompilerResultsLog: Info ]
CompilerResultsLog:Error: Error C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Source\MinecraftUE4\Wieldable.cpp(18) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CompilerResultsLog:Error: Error C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Source\MinecraftUE4\Wieldable.cpp(19) : warning C4996: ‘USceneComponent::AttachTo’: This function is deprecated, please use AttachToComponent instead. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile
.
CompilerResultsLog:Error: Error C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Engine\Classes\Components/SceneComponent.h(615) : note: see declaration of ‘USceneComponent::AttachTo’
CompilerResultsLog: Info ERROR: UBT ERROR: Failed to produce item: C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Binaries\Win64\UE4Editor-MinecraftUE4-9740.dll
CompilerResultsLog: Info Total build time: 25.76 seconds (Local executor: 0.00 seconds)
LogMainFrame: MainFrame: Module compiling took 26.050 seconds
Warning: HotReload failed, recompile failed
LogVSAccessor:Warning: Couldn’t goto line number ‘18’ in ‘C:\Users\George\Documents\Unreal Projects\MinecraftUE4\Source\MinecraftUE4\Wieldable.cpp’
LogSlate: Took 0.023407 seconds to synchronously load lazily loaded font ‘…/…/…/Engine/Content/Editor/Slate/Fonts/DroidSansMono.ttf’ (77K)