Reputation: 31
I have a simple jumping animation that I am trying to display in AR with ARKit.
It generally works, but I'm having some translation and anchoring issues.
This video demonstrates the problem. The character moves with the camera, rather than staying anchored while the camera moves around it.
I have very little experience with AR, ARKit, and animation in general (I am a developer), and am wondering if anyone can identify some obvious issues that might be a root cause of this problem.
Upvotes: 1
Views: 250
Reputation: 31
Turns out my model was huge relative to the world space- like a kilometer tall, but also a kilometer away from the camera. So you could pan properly, but of course moving a few meters forward and backward didn't appear to have an effect.
Scaled my model down to 0.1% and everything is working properly.
Upvotes: 2
Reputation: 491
This looks like a tracking problem - do you add the model only once tracking has been initialised?
func session(_ session: ARSession, didUpdate frame: ARFrame) {
if let state = self.sceneView.session.currentFrame?.camera.trackingState {
switch(state) {
case .normal:
// tracking is ready - add your model now.
case .notAvailable:
break
case .limited(let _):
break
}
}
}
Try using
self.sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints, ARSCNDebugOptions.showWorldOrigin]
in your viewWillAppear()
method. If you don't see any feature points (or it doesn't look like they're tracking very well) then you know that that is the problem.
Also if the world origin (the multi-coloured lines) seem to move around too then it is definitely the tracking.
The only way to rectify this is to use a spot that's better lit and has more features. And also wait for a bit longer before placing the model so that tracking has a better chance of becoming stable.
Upvotes: 0