Announcement

Collapse
No announcement yet.

How does this work? Events->TriggerEvent

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How does this work? Events->TriggerEvent

    Hi Guys, im looking at the shooter demo and come across something that i cant seem to figure out or find documentation on, could someone enlighten me

    Code:
    const UWorld* World = GetWorld();
    const IOnlineEventsPtr Events = Online::GetEventsInterface(World);
    const IOnlineIdentityPtr Identity = Online::GetIdentityInterface(World);
    
    if (Events.IsValid() && Identity.IsValid())
    {
           AShooterPlayerController* PC = Cast<AShooterPlayerController>(Pawn->Controller);
           if (PC)
           {
                  ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(PC->Player);
    
                 if (LocalPlayer)
                 {
                           const int32 UserIndex = LocalPlayer->GetControllerId();
                          TSharedPtr<const FUniqueNetId> UniqueID = Identity->GetUniquePlayerId(UserIndex);
                          if (UniqueID.IsValid())
                          {
                                   FVector Location = Pawn->GetActorLocation();
    
                                   FOnlineEventParms Params;
    
                                  Params.Add( TEXT( "SectionId" ), FVariantData( (int32)0 ) ); // unused
                                  Params.Add( TEXT( "GameplayModeId" ), FVariantData( (int32)1 ) ); // Todo determine game mode (ffa v tdm)
                                  Params.Add( TEXT( "DifficultyLevelId" ), FVariantData( (int32)0 ) ); // unused
    
                                 Params.Add( TEXT( "ItemId" ), FVariantData( (int32)Weapon->GetAmmoType() + 1 ) ); // Todo come up with a better way to determine item id, currently health is 0 and ammo counts from 1
                                 Params.Add( TEXT( "AcquisitionMethodId" ), FVariantData( (int32)0 ) ); // unused
                                 Params.Add( TEXT( "LocationX" ), FVariantData( Location.X ) );
                                 Params.Add( TEXT( "LocationY" ), FVariantData( Location.Y ) );
                                 Params.Add( TEXT( "LocationZ" ), FVariantData( Location.Z ) );
                                 Params.Add( TEXT( "ItemQty" ), FVariantData( (int32)Qty ) );
    
                                Events->TriggerEvent(*UniqueID, TEXT("CollectPowerup"), Params);
                         }
                }
    }
    }
    the "Events->TriggerEvent(*UniqueID, TEXT("CollectPowerup"), Params);"

    I can see it gets the GetEventsInterface near the top, which in itself im not familiar with, i cant see an endpoint that this gets received at or what listens to it?
    could someone tell me how this TriggerEvent system works please?

    ive searched everywhere and cant seem to find the correct documentation on how this functions and its driving me a bit insane

    Kind regards

    #2
    Hello @Saragan!

    I'm not experience with the OnlineSubsystem, but this function seems to simply call events associated to an actor:
    https://docs.unrealengine.com/en-US/...ent/index.html

    It is provided as an interface so that any class implementing this interface will have to provide its concrete behavior:
    Engine\Plugins\Online\OnlineSubsystem\Source\Public\Interfaces\OnlineEventsInterface.h

    i cant see an endpoint that this gets received at or what listens to it?
    Have you checked inside the item with your UniqueID to see if that has an event called CollectPowerup?

    If that doesn't exist, maybe you could create one yourself just to check if everything works as expected?

    If you need help here, maybe these links might be helpful:
    https://forums.unrealengine.com/deve...lained-finally
    https://docs.unrealengine.com/en-US/...tom/index.html

    Hope that helps!
    Last edited by Tapioca Dreams; 06-30-2020, 10:21 AM.

    Comment


      #3
      That's not what it's for.

      There is no defined endpoint. The Online Subsystem is a way to interact with different online services in an abstract way (so that your game code doesn't have to care if you're running on Steam or Xbox Live, etc.)

      If an online service has an "events" system, this interface acts as an intermediatte and generic wrapper between your game and the online service. AFAIK, none of the default subsystems have an implementation for the events interface. ShooterGames code exists just as an example.

      Comment


        #4
        Oh, I see! Thanks for the clarification, TheJamsh! Please, disregard my response, Saragan!

        Comment


          #5
          Hi Guys, sorry for the late reply (was AFK yesterday) thanks for replies.

          Hi Tapioca Dreams, no worries, any information is helpful, even those links you provided, they were a good read,

          Hi The Jamsh, so are we saying here in this case that the shooter game is just filling in some requirements to use an event system that hasnt been implemented as a demonstration of how to use it?

          so as being part of online services, can i assume that it it could go from recording information in databases for how many pickups a player has collected over a lifetime, notify other players or post notifications to mobile phones to say player is playing x and has picked up a item (annoying that would be for everyone )

          would/could it be used in a similar fashion as client/server/multicast implementations of functions and have it send a message to all clients in the area or do you reckon this is something beyond the sane use of this events system?

          just trying to further understand the use of it as it was a bit red herring for me now i know it wasnt just me and i wasnt going mad, the code really didnt exist haha.

          Thanks for your time guys, really appreciate it.,

          Comment

          Working...
          X