x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Event handling error C++

Hello everyone!

I am currently working on a game using C++ as the primary way to control the different aspect of my game, but I am running into a lot of errors when it comes to handle events: I had a look at the wiki page concerning events handling , and other snippets of code that come from various tutorial.

I can also do it in Blueprint but I want to know why my C++ solution is not working , here is a screen of my BP, the part circled in red is what I want to reproduce trough the code : alt text

Here is the code I tried to use without success:

 //foo.h
 
 class Afoo : public ADestructibleActor
 {
 GENERATED_UCLASS_BODY()
 
 UFUNCTION()
 void OnDestruction(float Damage, class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser);
 
 
 }
 
 //foo.cpp
 
 Afoo::Afoo(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {    
  OnTakeAnyDamage.AddDynamic(this, &Afoo::OnDestruction);
 }
 
 void Afoo:OnDestruction(float Damage, class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser)
 {
  if (GEngine)
     {
         GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("Custom Function Called")));
 
     }
 }

The error message I have is : error C2664: 'void TBaseDynamicMulticastDelegate_FourParams::__Internal_AddDynamic(UserClass ,void (__cdecl ATarget:: )(Param1Type,Param2Type,Param3Type,Param4Type),const FString &)' : cannot convert argument 2 from 'void (__cdecl ATarget:: )(float,UDamageType ,AController ,AActor )' to 'void (__cdecl ATarget::* )(Param1Type,Param2Type,Param3Type,Param4Type)' with

      [
           UserClass=ATarget
   ,            Param1Type=float
   ,            Param2Type=const UDamageType *
   ,            Param3Type=AController *
   ,            Param4Type=AActor *
       ]

       and

       [
           Param1Type=float
  ,            Param2Type=const UDamageType *
  ,            Param3Type=AController *
   ,            Param4Type=AActor *
       ]

      Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


If I try to add the delegate in foo.h ,

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FTakeAnyDamageSignature, float, Damage, class UDamageType * ,DamageType, class AController * ,InstigatedBy, class AActor*, DamageCauser);

like it is explained in the wiki got this error message :

Can't override delegate signature function 'TakeAnyDamageSignature_DelegateSignature'

Cheers,

Tryso

Product Version: Not Selected
Tags:
bp_event.png (202.9 kB)
more ▼

asked Sep 16 '14 at 09:53 AM in C++ Programming

avatar image

Tryso
8 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
 DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams( FTakeAnyDamageSignature, float, Damage, const class UDamageType*, DamageType, class AController*, InstigatedBy, class AActor*, DamageCauser );


Here the FTakeAnyDamageSignature already declare so you can not override, and for the first error your OnDestruction mus be like this:

 void OnDestruction(float Damage, const class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser);

It's const class UDamageType* not class UDamageType*

more ▼

answered Sep 16 '14 at 10:18 AM

avatar image

Duncan Dam
3.1k 121 50 164

avatar image Tryso Sep 16 '14 at 12:06 PM

Damn I missed that, but why it is changing from the FTakeAnyDamageSignature that is provided in the official documentation ?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question