Skip to main content

Screen to Real World

Converts the position of the object in screen space to its corresponding position and rotation in real world space by performing a raycast.

screen to real world
note
  • The selected AR camera must have a Device Tracker component in the Inspector panel and the Tracking Mode must be set to World. Otherwise, both the position and rotation will return 0, 0, 0.
  • Effects that utilize this node cannot be previewed on desktop. To preview your effect, click Preview in TikTok and scan the QR code from the TikTok mobile app.
  • Effects with this node can only run on mobile phones with gyroscopes, gravity sensors, acceleration sensors, and rotation sensors. If any of these sensors are missing, you will see a prompt that states your mobile phone does not support this effect.
  • This node requires time for the camera to initialize. To ensure your effect runs smoothly, add a hint to prompt users to wait. For example, "Scanning space in 3...2...1."
  • For best results, prompt users to click or focus on a plane with high contrast or bold textures.
  • Deviation in the rotation returned by the node might occur in some cases. It is recommended to handle the rotation information separately to ensure that the object is always perpendicular to the plane.

Input

NameData TypeDescription
StartExecStarts the conversion from screen to world coordinates
AR CameraAR CameraThe camera to which the Device Tracker component is attached. Tracking mode must be set to World.
Screen PositionVec2The position of the object in screen space
Max Ray DistanceNumberThe maximum distance of a ray in meters. It can be 10 to 200 meters; the default is 100 meters.

Output

NameData TypeDescription
Hit SuccessExecExecutes the next node if an object is detected
Hit FailExecExecutes the next node if no object is detected
PositionVec3The position of the object in world space
RotationVec3The rotation angle of the object in world space