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. 

Function already has a body (interface)

Hello, When I'm trying to compile my project an error :

 Error    C2084    function 'void IIDamageable::DamageResult(int32)' already has a body

pops up

My .h:

 #pragma once
 
 #include "Object.h"
 #include "IDamageable.generated.h"
 
 
 /**
  * 
  */
 UINTERFACE(MinimalAPI)
 class UIDamageable : public UInterface
 {
     GENERATED_UINTERFACE_BODY()
         
     
     
     
 };
 class IIDamageable
 {
     GENERATED_IINTERFACE_BODY()
     
         virtual void TakeDamage(int32 Damage);
     
         virtual int32& GetMaxHealth() = 0;
     
         virtual int32& GetCurrentHealth() = 0;
     UFUNCTION(BlueprintImplementableEvent, Category = "Character")
         void DamageResult(int32 cHealth);
 };

and .cpp

 #include "Project.h"
 #include "IDamageable.h"
 #include "Engine.h"
 
 
 
 UIDamageable::UIDamageable(const class FObjectInitializer& ObjectInitializer)
     : UInterface(ObjectInitializer)
 {
     
 }
 
 void IIDamageable::TakeDamage(int32 Damage)
 {
     GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "Base class error");
 }
 
 void IIDamageable::DamageResult(int32 cHealth)
 {
     GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "Base class error");
 }



Product Version: UE 4.10
Tags:
more ▼

asked Dec 17 '15 at 10:01 AM in C++ Programming

avatar image

Mily2206
66 6 8 12

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

2 answers: sort voted first

Change to this in your .h:

 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Character")

and in your .cpp:

 void IIDamageable::DamageResult_Implementation(int32 cHealth)

For a thorough explanation, here is a video (I think you can start at part 3 which is the link, but if you have doubts, you can check the first two parts as well):

https://www.youtube.com/watch?v=ChNdjECkvZs&list=PL5FKAcgXGa8RoR6oboATSZ45wLK2R3B-g&index=2

Another useful source:

https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Interfaces/index.html

more ▼

answered Dec 18 '15 at 09:19 PM

avatar image

rantrod
1.5k 49 47 216

(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