Ray Cast for screen touch to world space

i’m new to use effect house.
but i want to make mini shooting games using AR , i was try the ray cast method to detect 3D game object from screen space to world but it never works. can anybody here help me to detect 3D collider or game from screen space to world ?


Certainly! To detect 3D colliders or game objects from screen space to world space in AR:

  1. Set up your AR environment.
  2. Convert screen coordinates to a 3D ray using your AR framework’s methods.
  3. Cast the ray into the 3D scene using raycasting.
  4. Check for collisions with 3D objects, ensuring they have colliders attached.

If you’re using Unity, here’s a simple example in C#:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit)) {
GameObject hitObject = hit.collider.gameObject;
// Handle the hitObject as needed.
Make sure to replace Camera.main with your AR camera if it’s different.