• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by highpockets · Mar 31, 2020 at 12:13 PM · augmented-realityaugmented reality

ARSubsystems TrackableID of a plane that is hit returning null

Hello,

I'm working with AR Foundation at the moment and I'm having an issue with returning the TrackableID of the hit ARPlane after an ARRaycast succeeds. Here is the code I'm using:


 List<ARRaycastHit> _hits = new List<ARRaycastHit>();
 
 if(_raycastManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), _hits, TrackableType.Planes))
 {
                     
   TrackableId _planeID = _hits[0].trackableId;
   print(_planeID);
   ARPlane _arPlane = _arPlaneManager.GetPlane(_planeID);
   print(_arPlane);

   Vector3 _arPlaneNormal = _arPlane.normal;
   Vector3 _hitPos = _hits[0].pose.position;
   Vector3 _planeProjection = Vector3.ProjectOnPlane(_hitPos, _arPlaneNormal);
   Vector3 _camPos = Camera.main.transform.position;
   Vector3 _targetPos;



_planesID is null every time even though the Raycast succeeds. How is this even possible?? I would assume that every ARPlane has a TrackableID, regardless of the type of plane (listed below), or is this assumption incorrect??


The expected behaviour after setting the final Raycast arg to TrackableTypes.Planes would be that it returns true if it actually hits a plane and thus there should be a TrackableID available.


In the meantime, I'm going to try to narrow down the TrackableTypes I Raycast against.


If anyone can shed some light on this, I would be grateful and I will report back if it is indeed because of the TrackableTypes of planes.


PlaneEstimated
Refers to an estimated plane.


Planes
Refers to any of the plane type trackables.


PlaneWithinBounds
Refers to the 2D rectangular bounding box that tightly encloses the plane's polygon.


PlaneWithinInfinity
Refers to the infinite plane described by its Pose (a position and orientation).


PlaneWithinPolygon
Refers to 2D convex shape associated with a plane's boundary points.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by highpockets · Mar 31, 2020 at 02:30 PM

Ok, so I don't like answering my own questions, but I found the issue and it was because whatever plane was getting hit, did not have an ID. So once I set TrackableType to PlaneWithPolygon, it started working. So I'm back in business here. It may have been PlaneEstimated that was getting hit first off and although I wasn't able to track any documentation down that suggests that PlaneEstimated doesn't have a TrackableId, it seems like a likely culprit. Hopefully this helps someone in the future.


Cheers,

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unitydevstudio · May 26, 2020 at 05:42 PM 0
Share

I had exact same problem and couldn't know why it returns null. Thank you for your answer!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

137 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Time based Augmented Reality application 0 Answers

Is Unity 3D suitable for a furniture augmentation app? 1 Answer

What do you call image-marker recognition from device camera, without AR tracking. 0 Answers

Hololens: Share a WorldAnchor between individual apps 0 Answers

how can play many video with use menu in augmented reality,how to play many video with menu in augmented reality? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges