I'd like to trigger an event, in particular I'd like to load another scene when the camera node transform property is similar to a particular target transform.
Is it possible?
I thought about computing a distance between the camera transform and my target transform, but I don't know how to compute this distance. Any idea?
The measure of similarity does not need to be super precise but it has to be efficient since it has to run at 60fps.
Thank you
Giohn
If you only need to compare the distance between the camera and the node to trigger your event, then there are two approaches:
You could add a physics body to the node that represents the trigger volume, add a physics body to the camera to detect collisions with the trigger volume, and then receive the contact in your SCNPhysicsContactDelegate. For more info about SceneKit physics contacts, see SCNPhysicsContact
You could calculate the distance between the node and the camera every frame in the SCNSceneRendererDelegate. You could utilize the convertPosition(_:to:) method to get the position of one node relative to the other, and then calculate the distance by calculating the magnitude of that position.