Initialization
Follow the steps below to initialize and use the plugin.
Check out the below video for a quick walkthrough.
- You will need the following from the EOS Developer Portal:
PRODUCT_IDSANDBOX_IDDEPLOYMENT_IDCLIENT_IDCLIENT_SECRET
- You also need to provide these values yourself:
PRODUCT_NAME- A name chosen by you for the projectPRODUCT_VERSION- A version chosen by you for the projectENCRYPTION_KEY- A random 64 character long string
Now at the start of your game, or when you want to initialize EOS. Use the following script:
extends Node
func _ready() -> void:
# This will control which logs you get from EOSG
HLog.log_level = HLog.LogLevel.INFO
var init_opts = EOS.Platform.InitializeOptions.new()
init_opts.product_name = "PRODUCT_NAME_HERE" # Change this
init_opts.product_version = "PRODUCT_VERSION_HERE" # Change this
var create_opts = EOS.Platform.CreateOptions.new()
create_opts.product_id = "PRODUCT_ID_HERE" # Change this
create_opts.sandbox_id = "SANDBOX_ID_HERE" # Change this
create_opts.deployment_id = "DEPLOYMENT_ID_HERE" # Change this
create_opts.client_id = "CLIENT_ID_HERE" # Change this
create_opts.client_secret = "CLIENT_SECRET_HERE" # Change this
create_opts.encryption_key = "ENCRYPTION_KEY_HERE" # Change this
# Enable Social Overlay on Windows
if OS.get_name() == "Windows":
HAuth.auth_login_flags = EOS.Auth.LoginFlags.None
create_opts.flags = EOS.Platform.PlatformFlags.WindowsEnableOverlayOpengl
# Initialize the SDK
var init_res := await HPlatform.initialize_async(init_opts)
if not EOS.is_success(init_res):
printerr("Failed to initialize EOS SDK: ", EOS.result_str(init_res))
return
# Create platform
var create_success := await HPlatform.create_platform_async(create_opts)
if not create_success:
printerr("Failed to create EOS Platform")
return
# Setup Logs from EOS
HPlatform.log_msg.connect(_on_eos_log_msg)
# This will control which logs you get from EOS SDK
var log_res := HPlatform.set_eos_log_level(EOS.Logging.LogCategory.AllCategories, EOS.Logging.LogLevel.Info)
if not EOS.is_success(log_res):
printerr("Failed to set logging level")
return
HAuth.logged_in.connect(_on_logged_in)
# During development use the devauth tool to login
HAuth.login_devtool_async("localhost:4545", "CREDENTIAL_NAME_HERE")
# Only on mobile device (Login without any credentials)
# await HAuth.login_anonymous_async()
func _on_logged_in():
print("Logged in successfully: product_user_id=%s" % HAuth.product_user_id)
# This method is called when we get a log message from EOS SDK
func _on_eos_log_msg(msg: EOS.Logging.LogMessage) -> void:
print("SDK %s | %s" % [msg.category, msg.message])
Initialization on Windows
To use the Account Portal login option on Windows, you need to bootstrap Godot with EOS. See the steps below.
Bootstrapping Godot with EOS for Windows
Follow the tutorial at Redistributable Installer and also see the below steps.
A sample of the generated .ini file for the Godot Editor is shown below (during game development):
ApplicationPath=APPLICATION_PATH_HERE
WorkingDirectory=
WaitForExit=0
NoOperation=0
In the above .ini file, the APPLICATION_PATH_HERE can either be the path to your Godot Editor executable (Eg. Godot_v4.2.0-stable_win64.exe) when you are in development or the path to the exported game (Eg. MyAmazingGame.exe)
Initialization on Android
The plugin supports the Android platform, but needs a few one-time steps to initialize and configure android exports.
Pre-requisites
-
Setup the
Android Build Templatein your Godot project by following the tutorial Gradle builds for Andriod. This will create an android project inres://android/build. -
Now with reference to the tutorial Add the EOS SDK to Your Android Studio Project, perform the following steps.
-
In the
res://android/build/build.gradlefile, add the following lines after the implementations in thedependenciessection.dependencies {
implementation libraries.kotlinStdLib
implementation libraries.androidxFragment
// Add these lines
// 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'
// Update the path so that it points to eossdk-StaticSTDC-release.aar provided in addons/epic-online-services-godot/bin/android/
implementation files('../../addons/epic-online-services-godot/bin/android/eossdk-StaticSTDC-release.aar')
...other code -
In the
res://android/build/build.gradlefile, add the following lines after thedefaultConfigin theandroidsection.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'
// Add these lines
// 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 -
In the
res://android/build/config.gradlefile, update theminSdkto23to match with the requirements of theEOS Android SDK.Before
minSdk : 21,After
minSdk : 23, -
In the
res://android/build/src/com/godot/game/GodotGame.javafile, 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);
}
} -
Now open your project in the Godot Editor, and goto
Project -> Exportand create a new Android export profile. -
In the
Gradle Buildsection, enableUse Gradle Build. In theArchitecturessection enablearm64-v8a. In thePermissionssection ensure thatACESSS_NETWORK_STATE,ACCESS_WIFI_STATEandINTERNETare enabled. These permissions are needed for the EOS SDK to work. Fill in the other details such as package name, etc as needed. -
You can now export the Android APK by clicking the
Export Projectbutton.
Initialization on iOS
Export the project from Godot editor for iOS target. You might get a build error during this process, ignore it. Open the generated iOS project in XCode and build the project. The build should be successful. EOSG has support for iOS arm64 device and iOS arm64 simulator.