Friday, January 2, 2015

OpenCV vs Android vs UE4

Here goes another combination of system.
OpenCV provides native camera access for android, which is great for UE4. It came with two set of libraries .a and .so.  The .a libraries simply added to UE4 build system without any problems (in .build.cs, insert PublicAdditionalLibraries.Add(...) )
.so is a more tricky. In order to get camera preview, libnative_camera_r???.so has to be packed into the android apk (opencv will look for one on opening a VideoCapture). To add that .so, I use a hacked approach, I insert the following line into CopySTL in UEDeployAndroid.cs of the UnrealBuildTool:
File.Copy("[CVAndroidSDKPath]/sdk/native/libs/armeabi-v7a/libnative_camera_r4.4.0.so", UE4BuildPath + "/libs/" + Arch + "/libnative_camera_r4.4.0.so");

And that is it...

Monday, December 1, 2014

UE4 IOS FB Integration

critical steps required for ue4 integration with fb sdk (as a check list)

  • get the ue4 source
  • get facebook sdk
  • add #import <FacebookSDK.h>
  • Important issue, that I missed (the facebook sdk will not call completion handler):
    http://stackoverflow.com/questions/16730408/facebook-ios-sdk-not-calling-completion-handler-when-authorized-app
  • some (or most of) FacebookSDK documents are deprecated... but some seems to work fine.
    https://developers.facebook.com/docs/ios/share?locale=en_GB
  • ensure that Core.build.cs, and [yourproject].build.cs includes the Facebook SDK framework I used:
  • PublicAdditionalLibraries.Add("[FacebookSDK.framework's path]/Versions/A/FacebookSDK");
  • PublicSystemIncludePaths.Add("[FacebookSDK.framework's path]/Versions/A/Headers");


--


Thursday, November 27, 2014

UE4 Tilt Rotation Gimbal Lock

UE4 disappointed me again. The getInputMotionState function returns device's tilt in euler angles which can be very unstable due to gimbal lock. I need to implement my own native functions to get tilt as quaternion.

Tuesday, October 21, 2014

UE4.4.3 info.plist for xcode debug

I'm trying to get location service to work on IOS:
http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/
And that requires a few modifications to info.plist.

ue4.4.3 xcode debug doesn't use same info.plist as what is set in ue4 editor.
the info.plist in project setting (and project folder) will be the one packaged.
the other plist that is used during xcode debug will be in UnrealEngine-4.4/Engine/Build/IOS/UE4Game-Info.plist.


in ue4.5.1, it seems that the debugger now uses info.plist in project setting...

Sunday, October 12, 2014

Client can't see AI Characters (if they are inactive)

My Hack Solution: Make sure that those ai characters take action once in awhile to solve this problem (like using MoveTo or SetFocalPoint).

AnimNotify does not always fire

AnimNotify can be VERY unreliable. It is possible (but with very low probability) that the notify is NOT fired even if the blend weight passes its MinTriggerWeight. From experiments, I found animnotify sometimes does not fire in both clients and server.

I don't know what causes this, however, I suspect that it is because of a lag that somehow cause the engine to skip the notify.

I first hypothesize that if I can set MinTriggerWeight to zero, the animnotify should always fire given the sequence is play. In Editor, MinTriggerWeight cannot be set to zero (it has to be a small positive value). I suspected that why I can't set this to zero. In C++, the MinTriggerWeight corresponds to the float variable TriggerWeightThreshold. That variable will be used in UAnimInstance::AddAnimNotifies to filter animnotifies. So I created a new class inheriting from AnimInstance class, then make sure that the smallest MinTriggerWeight will always trigger.

But I failed, animnotify does not always fire (at least on client, yet it seems to always fire on server). I suspected that was because of something else... at least I saw a warning saying something like servertrackposition doesn't agree with client's co-occur when the client animnotify doesn't fire ... I suspected that it could lead to notify skipping... Searching in the source code, the client animation montage Position is set to match ServerMontageTrackPosition. This small hack smells fishy... I need to investigate further. In FAnimMontageInstance::Advance, I found that the playing montage will harvest notifies inbetween PrevPosition and Position. However, the PrevPosition is set to "Position" (the same variable that was assigned when server-client track position mismatch) before the Position is advanced to the next... Animnotify from montage with root motion may not be fired because of this!

To fix this, we have to generate animnotifies when that Server-client track position mismatches occur. It is ok, if animnotifies doesn't have great impact gameplay. Yet, sometimes this can be extremely annoying, not to be able to rely on them.

Wednesday, October 8, 2014

Weird Stuff in UE4.4.3

I consider these as known bugs.

- Scaling is not replicated by default. Even spawning with non-unit-scale transform in blueprint does not produce correct results for clients.

- ChildActorComponent causes weird behavior on clients (w/ editor build)... One component spawns two child actor instances (two separated actors: one is owned by server and is replicated, the other is owned (authorized) by client)! But this behavior is gone in packaged build.