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"

Interface RPC?

Hi,

I am trying to create an "Interaction" interface that is using RPCs. Browsing the forums and the Answer Hub, I think it should be possible, but I haven't found an actual working example.

I have created an interface called "I_Interaction" with a "StartInteraction()" and a "StopInteraction()" function:

"I_Interaction.h"

 #pragma once
 
 #include "I_Interaction.generated.h"
 
 UINTERFACE()
 class MYGAME_API UI_Interaction : public UInterface
 {
     GENERATED_UINTERFACE_BODY()
 };
 
 class MYGAME_API II_Interaction
 {
     GENERATED_IINTERFACE_BODY()
 
     //Interface Functions
 
     UFUNCTION(Server, Reliable, WithValidation)
     virtual void StartInteraction();
 
     UFUNCTION(Server, Reliable, WithValidation)
     virtual void StopInteraction();
 };
 

"I_Interaction.cpp"

 #include "MYGAME.h"
 #include "I_Interaction.h"
 
 //Constructor
 UI_Interaction::UI_Interaction(const class FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
 {
 
 }


I am implementing the interface in an AActor derived class called "EQ_Overlord"

"EQ_Overlord.h"

 #pragma once
 
 #include "Interface/I_Interaction.h"
 #include "Entity/Entity_Overlord.h"
 #include "EQ_Overlord.generated.h"
 
 UCLASS(abstract)
 class MYGAME_API AEQ_Overlord : public AEntity_Overlord, public II_Interaction
 {
     GENERATED_BODY()
 
     //Declaring Constructor
     public: AEQ_Overlord();
 
 protected:
 
     virtual void StartInteraction_Implementation() override;
 
     virtual void StopInteraction_Implementation() override;
 };

"EQ_Overlord.cpp"

 #include "MYGAME.h"
 #include "EQ_Overlord.h"
 
 //Constructor
 AEQ_Overlord::AEQ_Overlord() :Super()
 {
 
 }
 
 //Interface Functions
 
 bool AEQ_Overlord::StartInteraction_Validate()
 {
     return true;
 }
 
 void AEQ_Overlord::StartInteraction_Implementation()
 {
 
 }
 
 
 bool AEQ_Overlord::StopInteraction_Validate()
 {
     return true;
 }
 
 void AEQ_Overlord::StopInteraction_Implementation()
 {
 
 }


I cannot compile this, I get the following errors:

  error C2509: 'StartInteraction_Validate': member function not declared in 'AEQ_Overlord'
 
 error C2509: 'StopInteraction_Validate': member function not declared in 'AEQ_Overlord'


Now what confuses me is that as far as I know, both an RPC and an Interface function should use an "_Implementation" suffix. How do I get around this? I have tried many other options, but I couldn't even get it to compile.

Is even calling RPCs through an interface possible? If so, how? I hope someone can shine some light on this for me.

Thanks!

Product Version: UE 4.15
Tags:
more ▼

asked Apr 29 '17 at 04:22 AM in C++ Programming

avatar image

Kontur
186 6 10 15

avatar image Kontur May 02 '17 at 06:34 AM

bumping this, as it is still unresolved

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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