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 cpunerd96 · Oct 14, 2011 at 08:56 PM · mousecoordinates

Detecting mouse position in 3d space.

alt text

I'm a bit of a beginner and I'm trying to figure out something that's been frustrating me. I'm trying to make Runescape like movement. Point and click. The technique I've decided on is that when the player clicks on the ground an object is created. That's what the MouseMove Object is that you see. The player will then move towards the mouse move object until his x and y coordinates match the MouseMove's coordinates. Then he will stop. The problem is the mouse position is obviously made up of 2d x and y coordinates and I can't figure out a method to convert them. Perhaps I don't even need to convert them? I don't know too much about it and I don't know if there is some other method I could use. I mainly use C#, but I will except JavaScript. If you post an example be sure to explain it as thoroughly as possible. 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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Graham-Dunnett · Oct 14, 2011 at 09:07 PM

Fire a ray from the camera (Physics.Raycast) into the scene through the pixel where the click occurs. This will give you the world space position of where the ray hits an object. You now have a 3d position in your world space. Move your player towards this point.

Comment
Add comment · Show 3 · 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 cpunerd96 · Oct 14, 2011 at 09:18 PM 0
Share

Thanks! I'll have to read up on what a ray is.

avatar image Graham-Dunnett ♦♦ · Oct 14, 2011 at 09:19 PM 0
Share

http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html

avatar image Sintua · Oct 14, 2011 at 09:30 PM 0
Share

Remember to upvote answers!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Get mouse positon in world coordinates on a plane? 2 Answers

Having trouble getting Custom Editor to get a world point. 4 Answers

How to get mouse position in World Space when in Editor Mode 1 Answer

Event System value of mouse position is wrong. 0 Answers

Find Mouse co-ordinates on click in a 2d environment 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