Green_6
(JosephSmith)
September 4, 2014, 9:09am
1
After fixing a bad definition error, i just got this. Any ideas?
error C2664: 'void TBaseDynamicMulticastDelegate_FiveParams<void,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &,FWeakObjectPtr>::__Internal_AddDynamic<AcoinBrick>(UserClass *,void (__cdecl AcoinBrick::* )(Param1Type,Param2Type,Param3Type,Param4Type,Param5Type),const FString &)' : cannot convert argument 2 from 'void (__cdecl AcoinBrick::* )(AActor *,UPrimitiveComponent *,int32,bool,FHitResult)' to 'void (__cdecl AcoinBrick::* )(Param1Type,Param2Type,Param3Type,Param4Type,Param5Type)'
Duncan_Dam
(Duncan_Dam)
September 4, 2014, 9:16am
2
Are you trying to bind some function to your delegate ? if that, can you show your delegate and function you want to bind ?
Green_6
(JosephSmith)
September 4, 2014, 9:36am
3
Not quite sure what delegates are, but i’ll show you some stuff that i think is relevant.
.h
UFUNCTION()
void OnCollision(AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, FHitResult SweepResult);
.cpp
CollisionPlate->OnComponentBeginOverlap.AddDynamic(this, &AcoinBrick::OnCollision, int32 OtherBodyIndex, bool bFromSweep, FHitResult SweepResult);
void AcoinBrick::OnCollision(AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, FHitResult SweepResult)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(0, 10.0f, FColor::White, TEXT("Begin Overlap"));
}
}
Your argumentsb still not fitting, i think this time problrm is that delegate expects const FHitResult & not just FHitResult, look on beggining of error you will see which types he expects.
Duncan_Dam
(Duncan_Dam)
September 4, 2014, 9:49am
5
oh, ok, OnComponentBeginOverlap is a delegate, it let you bind another function with same parameter to it, so you just need this
CollisionPlate->OnComponentBeginOverlap.AddDynamic(this, &AcoinBrick::OnCollision);
Green_6
(JosephSmith)
September 4, 2014, 11:15am
6
Thats what i already had, then i changed it, still no fix.
Duncan_Dam
(Duncan_Dam)
September 4, 2014, 11:52am
7
check OnComponentBeginOverlap of CollisionPlate, AcoinBrick::OnCollision must have exactly same parameter.
Green_6
(JosephSmith)
September 4, 2014, 12:58pm
8
Changed it, same error, been a very problematic process for me, asked like 3 or 4 questions on this
coinBrick.h
UFUNCTION()
void OnCollision(AActor * OtherActor, UPrimitiveComponent * OtherComp);
coinBrick.cpp
CollisionPlate->OnComponentBeginOverlap.AddDynamic(this, &AcoinBrick::OnCollision);
void AcoinBrick::OnCollision(AActor * OtherActor, UPrimitiveComponent * OtherComp,)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(0, 10.0f, FColor::White, TEXT("Begin Overlap"));
}
}
Green_6
(JosephSmith)
September 4, 2014, 1:12pm
9
Finally fixed by looking at the FPS Shooter tutorials collision segment, it appears i was missing some params, in the end i just changed to Hit.
From
void OnCollision(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
};
To
UFUNCTION()
void OnHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
From
void AcoinBrick::OnCollision(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
}
To
void AcoinBrick::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
this->Destroy();
}
}