Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddRaycast() always returns null #1149

Closed
kenhuang1964 opened this issue Jan 7, 2024 · 1 comment
Closed

AddRaycast() always returns null #1149

kenhuang1964 opened this issue Jan 7, 2024 · 1 comment
Labels
how to Explains how to accomplish something

Comments

@kenhuang1964
Copy link

I am trying to initialize persistent raycast according to https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/manual/features/raycasts.html but it always returns null. I am using AR Foundation 5.1.1 and my iPad, which has LIDAR.

Here is the relevant part of my code:

    private ARRaycastManager raycastManager;
    private Vector2 screenCenter;
    private ARRaycast persistentRaycast;

    private void Awake()
    {
        raycastManager = GetComponent<ARRaycastManager>();
        screenCenter = new Vector2(Screen.width / 2, Screen.height / 2);
        persistentRaycast = raycastManager.AddRaycast(screenCenter, 3.0f);
        if (persistentRaycast == null)
        {
            Debug.LogError("PersistentRaycast was not created successfully.");
        }
// ...
@kenhuang1964 kenhuang1964 added the how to Explains how to accomplish something label Jan 7, 2024
@andyb-unity
Copy link
Collaborator

Have you looked at the logs? I would expect there to be a relevant error message in the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
how to Explains how to accomplish something
Projects
None yet
Development

No branches or pull requests

2 participants