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"

Getting FOnlineSubsystemSteam

I'm trying to get the FOnlineSubsystemSteam singleton so I can detect if Steam is initialized before I try to host/join a multiplayer game and pop up an error if it's not. When I call IOnlineSubsystem::Get() and try to use Cast on the result I just get the compiler error:

 2>C:\Program Files\Epic Games\4.9\Engine\Source\Runtime\CoreUObject\Public\Templates\Casts.h(176): error C2664: 'FOnlineSubsystemSteam *TCastImpl<From,To,UObjectToUObject>::DoCast(UObject *)' : cannot convert argument 1 from 'IOnlineSubsystem *' to 'UObject *'
 2>          with
 2>          [
 2>              From=IOnlineSubsystem
 2>  ,            To=FOnlineSubsystemSteam
 2>          ]
 2>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
 2>          C:\EGS\DeathTractor\Source\DeathTractor\DTBPLibrary.cpp(127) : see reference to function template instantiation 'To *Cast<FOnlineSubsystemSteam,IOnlineSubsystem>(From *)' being compiled
 2>          with
 2>          [
 2>              To=FOnlineSubsystemSteam
 2>  ,            From=IOnlineSubsystem
 2>          ]

I know FOnlineSubsystemSteam inherits from IOnlineSubsystem so I'm not sure why this is failing. What modules do I need to include in my project or headers in the file to get this working? Or is there some other way I can find out if the Steamworks API is initialized?

Product Version: UE 4.9
more ▼

asked Sep 04 '15 at 05:29 PM in C++ Programming

avatar image

924 42 61 209

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

1 answer: sort voted first

From what I remember the OnlineSubsystems themselves are inaccessible to game projects by default. Two things you can do though:

  1. You can access the SessionInterface via GetSessionInterface, which will tell you whether or not the online subsystem you have can make sessions at all, which is a little more abstract and platform agnostic.

  2. You can get the OnlineSubsystemSteam as a generic OnlineSubsystem by calling the Get function with an FName like this:


or something similar. It will still be a generic online subsystem pointer, but if it returns anything you know it's a steam

/3. If you really want to tightly bind to steam, you can add Steamworks to your PublicDependencyModuleNames in your Project.Build.cs and call the Steam API functions directly. The ones you want are probably SteamClient and SteamAPI_IsSteamRunning

more ▼

answered Sep 04 '15 at 06:38 PM

avatar image

703 40 32 123

avatar image kgamble Sep 04 '15 at 08:18 PM

3 is what I ended up doing, was just wondering if there was an official way of doing it since there's a "IsSteamClientAvailable" function in the subsystem. Thanks.

avatar image mrooney Sep 04 '15 at 08:31 PM

Unfortunately, as far as I can tell, the support for the steamworks api is a bit lacking in favor of supporting the generic interfaces. It's not so bad since the api is really easy to use on its own, but using the platform specific parts that you'd expect to come with the various subsystems is more difficult than it could be, at least to my knowledge.

(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