To start the Godot engine, use RTNGodot.createInstance inside a runOnGodotThread block. You must pass the --display-driver parameter as embedded to allow Godot to be embedded within the React Native application.
Important Platform Notes:
- Android: It is recommended to store Godot assets in the
asset folder of the main package for better performance. You can pass a --path to a directory. - iOS: You can pass a
--main-pack path to a .pck file.
import { RTNGodot, runOnGodotThread } from "@borndotcom/react-native-godot";
import * as FileSystem from 'expo-file-system/legacy';
function initGodot() {
runOnGodotThread(() => {
'worklet';
if (Platform.OS === 'android') {
RTNGodot.createInstance([
"--verbose",
"--path", "/main",
"--rendering-driver", "opengl3",
"--rendering-method", "gl_compatibility",
"--display-driver", "embedded"
]);
} else {
RTNGodot.createInstance([
"--verbose",
"--main-pack", FileSystem.bundleDirectory + "main.pck",
"--rendering-driver", "opengl3",
"--rendering-method", "gl_compatibility",
"--display-driver", "embedded"
]);
}
});
}