Hello I am working on a interface that will handle all networked related stuff.
For sound and particles and i meet a little snag.
When writing this code i felt sort of clever, lol.
But i am failing with the inheritance of the interface to other gameplay classes like Items.
Now i made the interface like this.
// SoundAndParticleInterface.h
UINTERFACE(meta = (CannotImplementInterfaceInBlueprint))
class MYGAME_API USoundAndParticleInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class ISoundAndParticleInterface
{
GENERATED_IINTERFACE_BODY()
/* Called from client to server to call the multicast RPC method. */
UFUNCTION(Server, Unreliable, WithValidation)
virtual void SERVER_PlaySoundForEveryoneAtLocation(AActor* ParentActor, USoundCue* SoundToPlay, const FVector & LocationToPlayAt, FName AttachName, bool bFollow, float VolumeMultiplier, float PitchMultiplier);
/* Server calls this method and all clients currently connected. */
UFUNCTION(NetMulticast, Unreliable, WithValidation)
virtual void MULTI_PlaySoundForEveryoneAtLocation(AActor* ParentActor, USoundCue* SoundToPlay, const FVector & LocationToPlayAt, FName AttachName, bool bFollow, float VolumeMultiplier, float PitchMultiplier);
};
And then i have the Blueprint Function Library like this.
// PlaySoundAndParticlesLibrary.h
UCLASS(Blueprintable)
class MYGAME_API UPlaySoundAndParticlesLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/* Play Sound For Everyone at provided location.
* Handels replication using ISoundAndParticleInterface::.
* And will only be played on a actor with this interface.
* -------------------------------------------------------------------------------
* @Param: The actor that plays this sound in the world (player, door, weapon, ..)
* @Param: The Sound Cue to Play at the given location.
* @Param: The Vector location to play the given sound.
* @Param: Attach name of socket.
* @Param: If TRUE the sounds follows the parent in the world.
* @Param: Volume multiplier for this sound.
* @Param: Volume pitch Multiplier for this sound.
*/
UFUNCTION(BlueprintCallable, Category = "MP Play Sound And Effects")
static void PlaySoundForEveryoneAtLocation(AActor* ParentActor, USoundCue* SoundToPlay, const FVector & LocationToPlayAt, FName AttachName, bool bFollow, float VolumeMultiplier, float PitchMultiplier);
};
So this compiles fine until i go and try to add it to a class.
UCLASS()
class MYGAME_API AMyGameBaseItem : public AActor, public ISoundAndParticleInterface
{
GENERATED_UCLASS_BODY()
public:
..
};
And compiler gives me this error.
error C2259: 'AMyGameBaseItem' : cannot instantiate abstract class
Now i never intended for these methods to be over-ridden in the other classes only call the default one.
And it seems that also can become a problem, and am not sure if i can declare the RPC methods virtual?
Am seeing these error`s under the above one.
void ISoundAndParticleInterface::SERVER_PlaySoundForEveryoneAtLocation_Implementation(AActor *,USoundCue *,const FVector &,FName,bool,float,float)' : is abstract
Any advice be much appreciate at this point.
Cheers!
WCode