Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Exnihilon · Aug 21, 2014 at 05:00 AM · androidcameradistancemarker

How to compute real life distance between Android camera and an AR marker

Hello to all. I' m trying hard to finish an AR (Augmented Reality) project, but I cannot implement the following described functionality. I need to show a gameObject, a 3d model, upon recognition of the AR camera that runs the NyARToolkit plugin, inside a certain distance, e.g 1.5 meters (is it equal to 1.5 units in unity word?).

As soon as the user moves above the 1.5 meters distance form the marker on wall, the application should load a different level, e.g. with another 3d model.

I searched the forum for something similar and Googled also, but could not find something to much my needs on how to implement this functionality.

I though of coding, a RayCast coming from the AR camera gameObject and hitting the gameObject "model" on a collider, so it is on "true" state. When I move the gameObject "model" away, as if the user would moved away form the marker, I get next level loading, but only on play mode.

How can I match the Unity AR camera to the real device camera, so when I move the Android mobile way from marker, I get next level loaded?

Following is the code snippet I have tried, that needs to be matched to Android device also, to work as it should:

   #pragma strict
     var onMarker : GameObject
     function Update () {
     var hit : RaycastHit;
     var backwards = transform.TransformDirection(Vector3.back);
     Debug.DrawRay(transform.position, -backwards*10, Color.red);
     if(Physics.Raycast(transform.position, -backwards, hit, 10))
     if(hit.collider.gameObject.name =="Camera"){
     onMarker.SetActiveRecursively(true);                     
                          }
                          else{
                          onMarker.SetActiveRecursively(false);                     
                          
                          Application.LoadLevel ("scene1");
       }
     }
 

If someone is kind enough to post a sample or a tutorial, It would be great, as I' m a novice in Unity and scripting. Thank you all in advance for your time and answers.

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to measure the distance between an Augmented Reality marker and camera? 0 Answers

Keep camera at certain distance from character when rotating 3 Answers

Native camera FOV? 0 Answers

Camera moving in Unity3d Editor, but not on Android device 1 Answer

How to use Android Accelerometer(Left and right tilt) to turn a sphere object and camera in that direction? 1 Answer


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