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 czc5473 · Aug 08, 2018 at 09:57 AM · cursor

How to constrain cursor to surface?

Hello, I am making a virtual tour using 360 images applied to spheres. I would like to create a cursor (like the one used in google maps) that is constrained to the surface of the sphere. How could I go about doing this? Thank you!

Comment
Add comment · Show 1
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 Harinezumi · Aug 08, 2018 at 10:56 AM 0
Share

The easiest approach I can think of is to raycast your cursor position, and draw a separate cursor (for example with a particle system) where the raycast hits:

 Transform constrainedCursor = ...; // this is the Transform of the virtual cursor
 
 RaycastHit hit;
 if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) {
     constrainedCursor.position = hit.point;
 }
 // else handle when you don't hit the sphere

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Aug 08, 2018 at 10:43 AM

I'm not totally sure what you mean, but i guess you mean google streetview and not really maps? Google street view requires a lot of extra metadata. This includes at which height the floor is and also the rough geometry of the surrounding buildings. This geometry can be calculated from several different images from different perspectives but the algorithms requires are quite complicated.


In short assuming you have the required metadata where the floor is you can either build a mesh collider with that data and use Collider.Raycast to determine a point on the surface, or if you only have a floor you can simply use an infinite mathematical Plane and Raycast against that.


If this is not what you're after you have to be much more specific on what information you actually have and what the result should look like.

Comment
Add comment · 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
0

Answer by czc5473 · Aug 08, 2018 at 12:43 PM

Hello, thanks for the response. Yes, I did mean google street view. I do not have a floor, only the sphere with a reversed shader so that the 360 image is viewed from the inside.

alt text

Here, I have white rings in the sphere that act as a hotspot to transition into a different sphere by clicking on it.

It works fine but I would like to make it neater and copy the way the cursor in street view works (an arrow, confined to the ground plane, changes direction depending which way you orient the scene.) I hope this is specific enough.

Thanks again for your help


untitled.png (190.6 kB)
Comment
Add comment · 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

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

91 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

Related Questions

GUI cursor position off 1 Answer

how to stop mouse going out of the screen ? 9 Answers

How do I change the hardware cursor? 5 Answers

Waste of time with gui ... hover and behind 2 Answers

Setting the mouse position to specific coordinates 5 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