Reputation: 21
How should I get camera/GPS information from an Android device to the Unreal Engine? I have searched everywhere and I'm not sure how to proceed.
Do I write a Java application for Android that communicates with Unreal via JNI or is there a more direct way to access the camera/GPS from Unreal via C++ by including libraries?
Are there any APIs out there that already bridge this gap?
Thanks!
Upvotes: 2
Views: 1778
Reputation: 5665
Assuming you are using UE4. The concept of Unreal Engine4 is modules that can be used by C++ code not depending on the platform (whenever it is possible).
Basically You need to create a module with C++ interface and implementations for different platforms. Your module most probably will be in the /Engine/Source/Runtime/<module_name>
. It has to contain <module_name>.Build.cs
file for the UnrealBuildTool and two folders: Public
and Private
. The first one will contain headers with your interface of the required functionality. Private
should contain set of folders for specific platform e.g. Android
, IOS
. Each platform should implement functionality described in the interface. For android you'll have to use JNI bindings, for iOS you'll be needing native Objective-C calls to the iPhoneSDK.
The tricky part here is defining common interface for all platforms that will be do both setting up the given functionality and using all required features of it.
For references you can check WebBrowser
module that has separate android implementation with unreal's new JNI wrapper.
P.S. Modules you've created you can push to the UE4 repo as pull request. This will help others when they'll be needing same functionality as you.
Upvotes: 3