Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
2
Question by Nuno_Barros · Mar 22, 2017 at 12:16 PM · cameraobjectvuforiaaugmented-reality

[Unity Vuforia] Make an object move towards the camera

I'm trying to make a game that has augmented reality in it. I want to make a sphere come towards the vuforia camera when a player concludes a task that i already programmed, but i cant find out how to. I've tried using MoveTowards() but all it does is make it go up on a horizontal axis and not towards the camera on a vertical axis. Any help would be apreciated, thanks.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by anilhdas · Mar 22, 2017 at 05:05 PM

To move the sphere towards the camera, you can follow the steps.

  1. Rotate the object towards the camera using transform.lookAt().

  2. Use Vector3.moveTowards() and pass the current position, target position (camera's position - minimum distance from camera, if any) and the speed of the movement.

I would be able to help more accurately if you can tell me some more details such as will you want the sphere to disappear when the image target is lost or after a fixed amount of time?

If the sphere you're trying to move, is attached to any Image target in Vuforia, I recommend to move it out as it might cause issues in the movement of the sphere when the image target is lost and found again.

You can then enable and disable the object (Sphere) by registering to Vuforia events to get the callback OnTrackingFound​ and OnTrackingLost.

Hope it helps. Let me know if you have any further queries.

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 Nuno_Barros · Mar 22, 2017 at 05:20 PM 0
Share

Thats actually genius ^^ Thanks for replying as well! I can't test it today anymore but i'm gonna try it tomorrow and then ill get back with another reply Thanks again!

avatar image
1

Answer by Lucas7CL · Mar 22, 2017 at 02:17 PM

Hi, maybe you can scale the model so can be seen as it´s nearer. Try using coordinates based on the camera as (0,0,0) then move along the z axis. Hope it helps!

Comment
Add comment · Show 2 · 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 Nuno_Barros · Mar 22, 2017 at 02:34 PM 0
Share

Hey, thanks for the reply. The problem with me scaling the model to give the ilusion that its nearer is that im working with augmented reality, so if i look at it from the side it will still be on that same horizontal plane. :\ As far as moving the object in the z axis, how would i do that? Im still new to unity so im still very noobish at it, sorry! ^^ Thanks again for the help tho.

avatar image Lucas7CL Nuno_Barros · Mar 22, 2017 at 02:40 PM 0
Share

I will use a "ghost entity" one level up in the hierarchy of the 3D model. That entity you need to make it look to the camera always, use a script to do it. So, then when you need to move the object towards to camera you move along the z axis. If needed that object can be rotated and then use the moveTowards function. The trick is to use the ghost entity with script that makes look towards the camera, also you can scale it easly. Cheers!

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

131 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

Related Questions

No PostProcessing in Vuforia AR 0 Answers

Unity (Vuforia) doesn't recognize my PS Eye. 0 Answers

Vuforia: model disappears when getting closer to ImageTarget 2 Answers

Building an AR App, everything is Blurry: Using Unity and Vuforia 0 Answers

why my Scene camera is not redering the predefined setup when creating two scenes? (using Vuforia ARCamera and another simple camera on a second screen) 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