Giter VIP home page Giter VIP logo

epic-online-services-godot's Introduction

Epic Online Services Godot (EOSG)

Project Logo

Unofficial Epic Online Services wrapper for Godot Engine 4.2 (includes demo project)

Godot3   Epic Online Services 1.16.3

Supports Windows x64, Linux x64 and Android

Disclaimer: This project is NOT affiliated with Epic Games Inc or Godot Engine. It doesn't endorse Epic Online Services. This project and sample Godot scenes are provided solely for educational purposes and may or may not comply with Epic Games' Design Guidelines, if you plan to release a game make sure you read the Guidelines and any other steps needed to release a public game like asking for user consent, option to delete user data, website with privacy policy and license, etc.

The main branch is for Godot 4.2

The godot3-mono branch is for Godot 3 Mono (C#) (un maintained)

Features

  • Authentication (Epic Games, Steam, Discord, Anonymous etc)
  • Social Overlay on Windows
  • Achievements
  • Stats & Leaderboards
  • Lobby, Sessions and Multiplayer
  • Voice
  • Metrics
  • Mods
  • Player/Title data storage
  • Progression Snapshot
  • Reports and Sanctions
  • Ecommerce (Ecom Epic Games Store)
  • AntiCheat

Support Development

Making this project took a lot of time and effort, reading the Epic Online Services documentation countless times and testing each method in Godot. I would really appreciate if you could support the project in any way.

Buy Me A Coffee
Github Sponsor

Want to support in other ways? Contact me on Discord: @3ddelano

Join the Discord server for discussing suggestions or bugs: 3ddelano Cafe

Watch the playlist

Epic Online Services Tutorial series

Screenshots

  • Windows

  • Android

How does it work

This project uses GDExtension to wrap the Epic Online Services C SDK so that it can be easily used in Godot using GDScript, C#, etc with similar class hierarchy and static type support. It makes use of signals for sending events like user login, logout, achievement unlock, etc.

Installation

This is a regular plugin for Godot 4.2. To install the plugin follow the steps below:

  1. Goto the Releases section and download the latest release
  2. Extract the zip file and copy the addons/epic-online-services-godot folder into the res://addons/ folder of your project. If the res://addons does not exist, create it.
  3. In the Godot editor, goto Project->Project Settings->Plugins and enable the Epic Online Services Godot 4.2 (EOSG) plugin.
  4. Restart the godot editor.
  5. You can now use the plugin. Head to the Documentation for more information on how to use the plugin. Use the below starter script.
    # In main script
    extends Node
    
    func _ready() -> void:
        # Initialize the SDK
        var init_opts = EOS.Platform.InitializeOptions.new()
        init_opts.product_name = "PRODUCT_NAME_HERE"
        init_opts.product_version = "PRODUCT_VERSION_HERE"
    
        var init_res := EOS.Platform.PlatformInterface.initialize(init_opts)
        if not EOS.is_success(init_res):
            print("Failed to initialize EOS SDK: ", EOS.result_str(init_res))
            return
    
        # Create platform
        var create_opts = EOS.Platform.CreateOptions.new()
        create_opts.product_id = "PRODUCT_ID_HERE"
        create_opts.sandbox_id = "SANDBOX_ID_HERE"
        create_opts.deployment_id = "DEPLOYMENT_ID_HERE"
        create_opts.client_id = "CLIENT_ID_HERE"
        create_opts.client_secret = "CLIENT_SECRET_HERE"
        create_opts.encryption_key = "ENCRYPTION_KEY_HERE"
    
        # Enable Social Overlay on Windows
        if OS.get_name() == "Windows":
            create_opts.flags = EOS.Platform.PlatformFlags.WindowsEnableOverlayOpengl
    
        var create_success := EOS.Platform.PlatformInterface.create(create_opts)
        if not create_success:
            print("Failed to create EOS Platform")
            return
    
        # Setup Logs from EOS
        IEOS.logging_interface_callback.connect(_on_logging_interface_callback)
        var res := EOS.Logging.set_log_level(EOS.Logging.LogCategory.AllCategories, EOS.Logging.LogLevel.Info)
        if res != EOS.Result.Success:
            print("Failed to set log level: ", EOS.result_str(res))
    
        _anonymous_login()
    
    
    func _on_logging_interface_callback(msg) -> void:
        msg = EOS.Logging.LogMessage.from(msg) as EOS.Logging.LogMessage
        print("SDK %s | %s" % [msg.category, msg.message])
    
    
    func _anonymous_login() -> void:
        # Login using Device ID (no user interaction/credentials required)
    	# Note: Device ID login method is for mobile devices
    	# Note: It may not work on some desktops
    	# Note: Rather for testing using the Dev Auth tool login method
        var opts = EOS.Connect.CreateDeviceIdOptions.new()
        opts.device_model = OS.get_name() + " " + OS.get_model_name()
        EOS.Connect.ConnectInterface.create_device_id(opts)
        await IEOS.connect_interface_create_device_id_callback
    
        var credentials = EOS.Connect.Credentials.new()
        credentials.token = null
        credentials.type = EOS.ExternalCredentialType.DeviceidAccessToken
    
    	var user_login_info = EOS.Connect.UserLoginInfo.new()
        user_login_info.display_name = "Anon User"
    
        var login_opts = EOS.Connect.LoginOptions.new()
        login_opts.credentials = credentials
        login_opts.user_login_info = user_login_info
        IEOS.connect_interface_login_callback.connect(_on_connect_interface_login_callback)
        EOS.Connect.ConnectInterface.login(login_opts)
    
    func _on_connect_interface_login_callback(data: Dictionary) -> void:
        if not data.success:
            print("Login failed")
            EOS.print_result(data)
            return
    
        print_rich("[b]Login successfull[/b]: local_user_id=", data.local_user_id)

Development Setup

Pre-requisites

To develop this plugin, follow the below steps:

  1. Download/clone the repository.

  2. Extract the EOS C SDK zip downloaded from Epic Games, rename it to eos-sdk and paste it in the thirdparty/ folder. Refer to the below folder structure.

  3. Build the GDExtension plugin in debug mode (With debug symbols)

    # In root folder
    scons platform=<platform> target=template_debug dev_build=yes

    Eg. scons platform=windows target=template_debug dev_build=yes

  4. Build the GDExtension plugin for release (Optimized)

    # In root folder
    scons platform=windows target=template_release
  5. The built GDExtension library will be in the res://addons/epic-online-services-godot/bin/ folder of the sample project.

How to run the sample project?

The sample Godot project is located in the Sample folder

  1. Clone/Download the repo.

  2. Download the latest release from the Releases section and replace the existing /addons/epic-online-services-godot with the one from the Release (this includes the built shared libraries).

  3. Copy your credentials (Product Id, Sandbox Id, Deployment Id, Client Id, Client Secret) of your Epic Games "Product" from the Epic Games Dev Portal and paste them in Main.gd script in the relevant sections. The encryption key is a random 64 character long string. These credentials need to be kept as private as possible. One way is to make sure to encrypt all scripts when exporting the final game. (See Compiling with script key encryption)

  4. Configure your Product on the EOS Dev Portal with the following configuration:

  • In the Client Policies section in Product Settings, for the Client policy type choose Custom policy, enable the User is required and enable every features and action except Connect (Trusted Server Required). This will allow the sample to access the different services provided by Epic Online Services. In your actual game, the client policy is important and you should give minimal permissions to features.
  • In the Permissions section of Epic Account Services, enable all three: Basic Profile, Online Presence and Friends.
  • (Optional if you want some pre-made achievements) In the Achievements section in Game Services, use the Bulk Import option and import the HelloProduct.zip file located at res://HelloProduct.zip

Bootstrapping Godot executable with Epic Online Services

If you want to use the Account Portal login option in Epic Online Services, you need to bootstrap the Godot/Game executable as needed by EOS-SDK 1.15 and greater. See Redistributable Installer

A sample of the generated .ini file for the Godot Editor is shown below (during game development):

ApplicationPath=Godot_v4.2.0-stable_win64.exe
WorkingDirectory=
WaitForExit=0
NoOperation=0

Follow the instructions in Running the service for local development and:

  • During game development

    Bootstrap the Godot Editor executable (eg. Godot_v4.2.0-stable_win64.exe) to test the Account Portal login

  • After exporting the game

    Bootstrap the exported game executable (eg. My Amazing Game.exe)

Exporting for Android

Pre-requisites

  1. Extract the EOS Android SDK zip downloaded from Epic Games, rename it to eos-sdk and paste it in the thirdparty/ folder.

  2. Setup the Android Build Template in your Godot project by following the tutorial Gradle builds for Andriod. This will create an android project in res://android/build.

  3. Now with reference to the tutorial Add the EOS SDK to Your Android Studio Project, perform the following steps.

  4. In the res://android/build/build.gradle file, add the following lines after the implementations in the dependencies section.

    Before

    dependencies {
    	implementation libraries.kotlinStdLib
    	implementation libraries.androidxFragment
    	... other code
    

    After

    dependencies {
    	implementation libraries.kotlinStdLib
    	implementation libraries.androidxFragment
    	
    	// EOS SDK dependencies
    	implementation 'androidx.appcompat:appcompat:1.5.1'
    	implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    	implementation 'androidx.security:security-crypto:1.0.0'
    	implementation 'androidx.browser:browser:1.4.0'
    	implementation files('../../../thirdparty/eos-sdk/SDK/Bin/Android/static-stdc++/aar/eossdk-StaticSTDC-release.aar')
    
    	...other code
    
  5. In the res://android/build/build.gradle file, add the following lines after the defaultConfig in the android section.

    Before

    android {
    
    	... other code
    
    	defaultConfig {
    		... other code
    	
    		// Feel free to modify the application id to your own.
    		applicationId getExportPackageName()
    		versionCode getExportVersionCode()
    		versionName getExportVersionName()
    		minSdkVersion getExportMinSdkVersion()
    		targetSdkVersion getExportTargetSdkVersion()
    
    		missingDimensionStrategy 'products', 'template'
    	}
    
    	... other code
    

    After

    android {
    
    	... other code
    
    	defaultConfig {
    		... other code
    	
    		// Feel free to modify the application id to your own.
    		applicationId getExportPackageName()
    		versionCode getExportVersionCode()
    		versionName getExportVersionName()
    		minSdkVersion getExportMinSdkVersion()
    		targetSdkVersion getExportTargetSdkVersion()
    
    		missingDimensionStrategy 'products', 'template'
    
    		// This is needed by EOS Android SDK
    		String ClientId = "PUT YOUR EOS CLIENT ID HERE"
    		resValue("string", "eos_login_protocol_scheme", "eos." + ClientId.toLowerCase())
    	}
    
    	... other code
    
  6. In the res://android/build/config.gradle file, update the minSdk to 23 to match with the requirements of the EOS Android SDK.

    Before

    minSdk             : 21,
    

    After

    minSdk             : 23,
    
  7. In the res://android/build/src/com/godot/game/GodotGame.java file, update it as follows.

    package com.godot.game;
    
    import com.epicgames.mobile.eossdk.EOSSDK;     // added
    import org.godotengine.godot.GodotActivity;
    
    import android.os.Bundle;
    
    public class GodotApp extends GodotActivity {
    	static {                                   // added
    		System.loadLibrary("EOSSDK");          // added
    	}                                          // added
    	
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    		EOSSDK.init(getActivity());  // added
    		
    		setTheme(R.style.GodotAppMainTheme);
    		super.onCreate(savedInstanceState);
    
    	}
    }
  8. Now open your project in the Godot Editor, and goto Project -> Export and create a new Android export profile.

  9. In the Gradle Build section, enable Use Gradle Build. In the Architectures section enable arm64-v8a. In the Permissions section ensure that ACESSS_NETWORK_STATE, ACCESS_WIFI_STATE and INTERNET are enabled. These permissions are needed for the EOS SDK to work. Fill in the other details such as package name, etc as needed.

  10. You can now export the Android APK by clicking the Export Project button.

Current Project Status

  • Completed with sample

    • Auth Interface
    • Achievements Interface
    • Connect Interface
    • CustomInvites Interface
    • Friends Interface
    • Stats Interface
    • UserInfo Interface
    • Leaderboards Interface
    • Metrics Interface
    • Mods Interface
    • Presence Interface
    • ProgressionSnapshot Interface
    • Reports Interface
    • UI Interface
    • Version Interface
  • Completed without sample

    • KWS Interface
    • Lobby Interface
    • P2P Interface
    • PlayerDataStorage Interface
    • RTC Interface
    • Sanctions Interface
    • Sessions Interface
    • TitleStorage Interface
    • Ecom Interface
    • AntiCheatServer Interface
    • AntiCheatClient Interface
  • Not completed

    • Integrated Platform Interface

epic-online-services-godot's People

Contributors

3ddelano avatar alekslitynski avatar lowfire avatar paskausks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epic-online-services-godot's Issues

EOS Platform creation sometimes fails

I've noticed a strange issue that has been plaguing me for a while now as I've been using this plugin for my game projects. When creating the EOS platform, it sometimes just fails. I'm not entirely sure why. I haven't been able to reproduce exactly why it happens because it's occurrence feels random.

Capture

Just for a little context, the "multiplayer module" that's mentioned in the console is a high-level abstraction of the EOS platform that I've created to make using it's features much easier and streamlined (and I might post it one day). One of the things that the multiplayer module does is handle the creation and initialization of the EOS platform before any of it's other features can be used. As you can see from the console, it sometimes simply doesn't work. What I've done to get around platform creation sometimes failing was to setup a retry count and have the module retry creating the platform if it fails the first time. It retries platform creation at one second intervals to prevent it from running it every frame, which isn't really desirable. It goes on loop until either platform creation finally succeeds or until the max amount of retries is exceeded, in which case an error is thrown. This workaround is fine for the most part, but in certain rare occasions, platform creation just doesn't work at all and the module ends up exceeding max retries.

I can only guess why the platform fails to create. It could either be due to networking issues or something else. I'm not sure. I figured I'd bring this up because it doesn't look like anyone has pointed this out yet.

P2P

when do you think we will have p2p
thank you for the great work

p2p support

I would like to know when the p2p implementation will be added and ask for it

Not an actual bug, testing on Linux

I wanted to know how you are able to test this on Linux, there is no official EOS Launcher for Ubuntu.
Could you provide the steps to test this inside Linux (Ubuntu) a project?

Android support

Make the plugin to work on Android using the EOS Android SDK.

We can either do this using a custom Android Build template or a GodotAndroidPlugin with GDExtension.

Uploading Artifacts to Release

I know that the pipeline is uploading artifacts every time it builds, but is it possible to have those artifacts uploaded into release anytime there is a new build? I wanted to ask because it would make it much easier to grab them from a ci/cd pipeline since the url to the latest release will always be the same. My friend and I want to be able to easily grab the newest version of the plugin the second new changes become available.

BUG: Cannot build with scons

C:\Users\wiene\Downloads\epic-online-services-godot-main\epic-online-services-godot-main\thirdparty\eos-sdk\Include\eos_auth_types.h(297): note: see declaration of '_tagEOS_Auth_LoginCallbackInfo' src\auth_interface.cpp(42): error C2039: '__this': is not a member of '_tagEOS_Auth_LoginCallbackInfo' C:\Users\wiene\Downloads\epic-online-services-godot-main\epic-online-services-godot-main\thirdparty\eos-sdk\Include\eos_auth_types.h(297): note: see declaration of '_tagEOS_Auth_LoginCallbackInfo' cl /Fosrc\lobby_search.windows.template_release.x86_64.obj /c src\lobby_search.cpp /TP /std:c++17 /nologo /EHsc /O2 /MD /DTYPED_METHOD_BIND /DNOMINMAX /Igodot-cpp\gdextension /Igodot-cpp\include /Igodot-cpp\gen\include /Isrc /Ithirdparty\eos-sdk\Include scons: *** [src\auth_interface.windows.template_release.x86_64.obj] Error 2 lobby_search.cpp scons: building terminated because of errors.

Couldn't compile on Linux Mint 21.2 (base: Ubuntu 22.04 jammy)

Got error while compiling from the source - main

In file included from src/auth_interface.cpp:1:
src/ieos.h:261:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_get_friends_exclusive_input' [-fpermissive]
  261 |     bool IEOS::ui_interface_get_friends_exclusive_input(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:262:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_block_player' [-fpermissive]
  262 |     void IEOS::ui_interface_show_block_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:263:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_report_player' [-fpermissive]
  263 |     void IEOS::ui_interface_show_report_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:264:9: error: extra qualification 'godot::IEOS::' on member 'ui_interface_pause_social_overlay' [-fpermissive]
  264 |     int IEOS::ui_interface_pause_social_overlay(Ref<RefCounted> options);
      |         ^~~~
src/ieos.h:265:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_is_social_overlay_paused' [-fpermissive]
  265 |     bool IEOS::ui_interface_is_social_overlay_paused(Ref<RefCounted> options);
      |          ^~~~
In file included from src/achievements_interface.cpp:1:
src/ieos.h:261:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_get_friends_exclusive_input' [-fpermissive]
  261 |     bool IEOS::ui_interface_get_friends_exclusive_input(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:262:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_block_player' [-fpermissive]
  262 |     void IEOS::ui_interface_show_block_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:263:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_report_player' [-fpermissive]
  263 |     void IEOS::ui_interface_show_report_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:264:9: error: extra qualification 'godot::IEOS::' on member 'ui_interface_pause_social_overlay' [-fpermissive]
  264 |     int IEOS::ui_interface_pause_social_overlay(Ref<RefCounted> options);
      |         ^~~~
src/ieos.h:265:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_is_social_overlay_paused' [-fpermissive]
  265 |     bool IEOS::ui_interface_is_social_overlay_paused(Ref<RefCounted> options);
      |          ^~~~

And after a long wall of text:

es/xr_positional_tracker.linux.template_debug.dev.x86_64.o godot-cpp/gen/src/classes/xr_server.linux.template_debug.dev.x86_64.o godot-cpp/gen/src/classes/zip_packer.linux.template_debug.dev.x86_64.o godot-cpp/gen/src/classes/zip_reader.linux.template_debug.dev.x86_64.o godot-cpp/gen/src/variant/utility_functions.linux.template_debug.dev.x86_64.o
scons: *** [src/auth_interface.os] Error 1
scons: *** [src/achievements_interface.os] Error 1
In file included from src/connect_interface.cpp:1:
src/ieos.h:261:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_get_friends_exclusive_input' [-fpermissive]
  261 |     bool IEOS::ui_interface_get_friends_exclusive_input(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:262:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_block_player' [-fpermissive]
  262 |     void IEOS::ui_interface_show_block_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:263:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_show_report_player' [-fpermissive]
  263 |     void IEOS::ui_interface_show_report_player(Ref<RefCounted> options);
      |          ^~~~
src/ieos.h:264:9: error: extra qualification 'godot::IEOS::' on member 'ui_interface_pause_social_overlay' [-fpermissive]
  264 |     int IEOS::ui_interface_pause_social_overlay(Ref<RefCounted> options);
      |         ^~~~
src/ieos.h:265:10: error: extra qualification 'godot::IEOS::' on member 'ui_interface_is_social_overlay_paused' [-fpermissive]
  265 |     bool IEOS::ui_interface_is_social_overlay_paused(Ref<RefCounted> options);
      |          ^~~~
scons: *** [src/connect_interface.os] Error 1
ranlib godot-cpp/bin/libgodot-cpp.linux.template_debug.dev.x86_64.a
scons: building terminated because of errors.

Did everything that was told in the Readme

Vulkan Overlay

I have compiled the repo and did everything as the docs said and everything worked fine (using Compatibility mode).
When I switched to the Forward+ renderer, the overlay appears to load correctly but doesn't show up (the ui and logs indicates that it is working, but nothing renders to the screen).
I've tried doing some experiments with this in the past, but I couldn't even get it to load with vulkan, so I have no idea what may be happening here.

Linux Release

Are there any plans to release this plugin for Linux? I can see that the windows binaries are available for download, but what about Linux? I'm asking because my friend and I are running a ci/cd pipeline where we grab the windows binaries every time we export our game for windows. I can build the Linux binaries myself, but I figured it would be a bit easier and save a few steps if we could grab the Linux version of the plugin straight from the git repo instead of me having to build it every time there's an updated version.

P2P Sample Game

I've created a repo for a sample game that demonstrates the use of the P2P Interface and the EOSGMultiplayerPeer class and provides a simple example of how it can be used. The repo can be found here: https://github.com/LowFire/EOSGP2PInterfaceTestGame.

The sample game was requested in #13. It can be linked to in the readme if desired.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.