Seems that above â lat â cannot convert to double type properly.
@sunlite you should check if self.userLocation has a value and you should avoid using force unwrapped optionals unless you know 100% that they will have a value.
let ranAnnotations = getRanAnnotations(centerLatitude: lat!, centerLongitude: lon!)
@pierredrks But when tap an annotation which is within the valid distance, such as 50 meters as in your sample code ,same fatal error appears again when calling the camera, and then App crashes before camera responds. Please help, thanks
@pierredrks thanks, I solved the problem. Besides dae file, how can other 3D format files work for the AR_hunt, such as MAX. FBX. obj. mb ? I have tried to convert FBX. obj. mb files into dae file, but the converted dae files still failed to work.
@pierredrks I also tried other dae files from https://clara.io/library, such as : rabbit, princess-luna-season-1-high-resolution, test, Untitled Scene, piplup, Bear, Gato, Princess Twilight Sparkle, but none of those dae files worked for your Sample code!
Then I also tried other dae files from : https://3dwarehouse.sketchup.com/ , such as : tails, worm, writtle-tittle, lion-cub, but none of them works for your Sample code.
So shall I amend those dae files for them to wok for your Sample code?
Stuck here for a long time.
Please help.
thanks!
@sunlite Iâm not sure but i think that there is just a problem with the scaling/positioning of the objects inside the dae file. Maybe it helps to compare the values for position/size/scale with one of the working objects like the wolf.
@pierredrks with those unsuccessful dae files, crash before calling camera with the same error as previous: [quote=âsunlite, post:21, topic:26673â]
fatal error: unexpectedly found nil while unwrapping an Optional value
[/quote]
thanks
@pierredrks shall I adjust the values for position/size/scale within a 3D tool or within iOS code?
thanks
You can see and change the values in Xcode when you open the dae file. But you can also do it in code.
@pierredrks are following codes the all parts that you use in your sample for adjusting dae files? Thanks
if target.itemDescription == âdragonâ {
enemy?.position = SCNVector3(x: 0, y: -15, z: 0)
} else {
enemy?.position = SCNVector3(x: 0, y: 0, z: 0)
}
@pierredrks sorry, I am new to it. Which is the simplest way between your 2 methods? Preferably there is a web link to specify on how to do it. Thanks!
@sunlite yep this is the only place the dae file is adjusted.
The simplest way to compare the values is to open both files in Xcode and select the topmost part of the object.
Changing the values is both simple in code or in Xcode, but i think the most clean solution is to change it in the dae file. Otherwise youâll have a lot of if-else statements in your code.
Just an FYI!
I could only get this to work one time. Got multiple errors such as âcannot get carrierâŠâ and much more. See prior posts Just updated the phone to the latest version, 10.3 and Xcode 8.3. Everything now works perfectly without errors. And I can run it multiple times without any errors!
Hope this helps anyone else that canât get it to run.
Ron Cookson
@pierredrks Finally I can import other dae files.Sorry that I disturbed you so much before
How can I use dae and scn files together in your sample? thanks!
Hello. I just updated my phone to iOS 10.3.1 and Xcode to the latest version. Now when I run the final project and tap on a pin to enter camera mode, the program gets an exception error âfatal error: unexpectedly found nil while unrapping and optional valueâ. Error line looks to be in the map viewcontroller at line âself.present(viewcontroller ,animated:true, completion:nilâ. Checked ARViewcontroller is the correct name. Anyone else getting this or can help?
Thanks
Ron cookson
Great tutorial! Much to learn here, so thanks for all the detail.
One minor problem - when I remove the third target, the red pin remains and selecting it does nothing. Is this a bug or a feature?
@ron_cookson maybe you make the same mistake with me. Try to make the âitemDescriptionâ in MapViewController same with the âtarget.itemDescriptionâ in ViewControllerâs setupTarget function. Try it!