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"

C++ interface function as NetMulticast function?

In multiplayer game I want to keep all useful items simulating physics and disable physics when character grab them. I found that physics is simulating on both sides(server and client), and I should call some NetMulticast function what disable all things I want. But this function is in interface

 #pragma once
 #include "PickableInterface.generated.h"
 class UPickableInterface : public UInterface
 class IPickableInterface
     UFUNCTION(NetMulticast, Reliable, Category = "Pickable Interface")
         void OnPickUp();

And I have Weapon class implementing OnPickUp function

 #pragma once
 #include "GameFramework/Actor.h"
 #include "Interfaces/PickableInterface.h"
 #include "ZzzzzWeapon.generated.h"
 class ZZZZZ_API AZzzzzWeapon : public AActor, public IPickableInterface
     virtual void OnPickUp_Implementation() override;
 void AZzzzzWeapon::OnPickUp_Implementation()
     UE_LOG(ZzzzzWeaponLog, Log, TEXT("%s is picked up"), *this->GetName());
 // WeaponBody is SkeletalMeshComponent used as Root

Item pickng up works next way: OnActorBeginOverlap calls server function TryToPickUp, which check is overlapped actor implements PickableInterface or not and attach it to Character and disabling physics if it is.

 #pragma once
 #include "GameFramework/Character.h"
 #include "Player/ZzzzzCharacterMovementComponent.h"
 #include "ZzzzzCharacter.generated.h"
 class ZZZZZ_API AZzzzzCharacter : public ACharacter
         void OnZzzzzCharacterBeginOverlap(AActor* OverlappedActor, AActor* OtherActor);
     UFUNCTION(Server, WithValidation, Reliable)
         void TryToPickUp(AActor* PickUpActor);
     void TryToPickUp_Implementation(AActor* PickUpActor);
     bool TryToPickUp_Validate(AActor* PickUpActor) { return true; }
     UPROPERTY(Replicated, EditDefaultsOnly, BlueprintReadOnly, Category = "Zzzzz Character Items", meta = (AllowPrivateAccess = true))
         FName HandItemSocket;
     UFUNCTION(NetMulticast, Reliable)
         void GrabToHand(AActor* GrabActor);
     void GrabToHand_Implementation(AActor* GrabActor);
 void AZzzzzCharacter::OnZzzzzCharacterBeginOverlap(AActor* OverlappedActor, AActor* OtherActor)
     if (Role < ROLE_Authority)
 void AZzzzzCharacter::TryToPickUp_Implementation(AActor* PickUpActor)
     if (Role == ROLE_Authority)
         if (PickUpActor != nullptr &&
             UE_LOG(ZzzzzCharacterLog, Warning, TEXT("%s is trying to pick up %s"), *this->GetName(), *PickUpActor->GetName());
             //IPickableInterface::Execute_OnPickUp(PickUpActor);<---- This interface NetMulticast function call just doesn't work
 void AZzzzzCharacter::GrabToHand_Implementation(AActor* GrabActor)
     if (GrabActor)
         IPickableInterface::Execute_OnPickUp(GrabActor); //<---- But here it works just like ordinary function
         GrabActor->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, HandItemSocket);

Problem is NetMulticast function(but from interface) doesn't fire as expected, but works like simple function in other NetMulticast function(character function for now).

Are UE4 C++ interfaces not designed for Remote Procedure Calls, or in this case main problem is bad code design?

Product Version: UE 4.12
more ▼

asked Jun 28 '16 at 02:43 PM in C++ Programming

avatar image

40 2 7 11

avatar image napolinkinpark3r Jul 04 '16 at 11:25 AM

Bump! Bump!

(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