Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 Marks4 · Dec 10, 2018 at 12:26 PM · raycastvuforiaeventsystemaugmented reality

How do I make raycasting work with easyAR's camera?

I want to use the EventSystem to detect a click on a sprite child of ImageTarget. I add the Physics 2D raycaster to the RenderCamera(EasyAR_Startup->ARCamera->RenderCamera) and a BoxCollider 2D to the sprite. It doesn't work. It works fine if I just use a normal camera(GameObject->Camera) on a non-AR experience though.

This is the component that I want to add to the sprite and make it work:

 using UnityEngine;
 using UnityEngine.EventSystems;

 public class ClickAction : MonoBehaviour, IPointerClickHandler
 {
     public void OnPointerClick(PointerEventData eventData)
     {
         Debug.Log("clicked");
     }
 }


Note: I put the vuforia tag because I couldn't find easyAR tag, and just thought that maybe vuforia users have the same problem and can help.

Comment
Add comment · Show 5
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 hec_91 · Dec 10, 2018 at 12:49 PM 0
Share

Did you try using 3D physics ins$$anonymous$$d of 2D?

avatar image Marks4 hec_91 · Dec 10, 2018 at 01:01 PM 0
Share

It's a sprite, it should work with physics 2D. And like I said, the code works on a non-AR experience.

avatar image hec_91 Marks4 · Dec 10, 2018 at 01:18 PM 0
Share

I know, but give it a try. $$anonymous$$aybe 2D physics doesn't work in AR for some reason. I never used it in AR, I don't know if it has some limitations. Also, what do you mean by "under the ImageTarget"? Is it a child of the ImageTarget or is it hidden behind it?

Show more comments

1 Reply

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

Answer by hec_91 · Dec 10, 2018 at 02:33 PM

I tried to do the same and it doesn't work for me either, but only if I use 2D physics. The thing with 2D is that colliders are only drawn on the XY plane, so they aren't affected by rotation, as you can see in this image: sprite So the sprite can rotate as you want, but the collider won't. This means that if the collider is perpendicular to the camera, it will appear as just a line, so it won't work.

Instead, using 3D physics it works just fine. I would advise you to do this: - Create a new material that uses the standard shader. - Set the rendering mode to Cutout and put your sprite into the Albedo field. - Put a quad or a plane in the scene and assing this material to it. - Put a 3D BoxCollider and your script on the new game object. - On the RenderCamera put a 3D Physics Raycaster, maybe with a Max Ray Intersection greater than 0 if you need it.

In my scene, it works.


sprite.png (56.0 kB)
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 Marks4 · Dec 10, 2018 at 05:27 PM 1
Share

Thank you! I wanted to upvote this like a million times.

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.

Follow this Question

Answers Answers and Comments

147 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help, Use event system IPointerClickHandler 1 Answer

How do ı acces dji matrice100 camera in my augmented reality application?(Using vuforia sdk) 0 Answers

Vuforia model target fails in Unity 2 Answers

Using Physics Raycaster and mouse move RaycastHit 0 Answers

Physics.Raycast only finds some objects 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