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 LisbetH200300 · Sep 09, 2012 at 03:09 AM · raycastcollidermathplanecoordinates

Raycast visual and moving text possition.

Hello Unity community,

We're a group of students finishing some volunteer assignment, about creating visual representations to younger math students. Currently we're creating an interactive mini game-program that at the end, will allow the user to navigate a point around in a 3 dimensional space, to understand certain things like Dist(p) formula, and geometric space easier. But we need some help!

The setup: We're using three planes, to represent the background of the geometric planes, and a point object inside the perimiter, I'd like to use something like raycast for:

(a) Project a visual line from the point in three directions, towards the planes.

(b) Extract the x,y,z coordinates from the point, and display at the point where the raycast collides with the plane, and move this point around as the point in space moves around.

Any help is greatly appreciated, and all coding contributions will be credited in the index of the entire teaching material.

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 LisbetH200300 · Sep 09, 2012 at 10:01 AM 0
Share

Additional information:

Currently using a debug solution to draw the lines:

Debug.DrawLine (PointPosition.position,Vector3(PointPosition.position.x,PointPosition.position.y,0), Color.red); Debug.DrawLine (PointPosition.position,Vector3(PointPosition.position.x,0,PointPosition.position.z), Color.red); Debug.DrawLine (PointPosition.position,Vector3(0,PointPosition.position.y,PointPosition.position.z), Color.red);

But this is a gizmo, and won't show up in-game obviously, so need an effect to replace this, preferably a dotted line or normal line. Also for b) I think using text, I could update the location in the world, by the same way (x,y,z) with one always being 0, so that's solved too, just need the actual lines drawn, anyone?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Sep 09, 2012 at 09:53 AM

You will need to use LineRenderer to draw your lines. It is probably not necessary to use a RayCast as you will know the distance from your point to your 3 planes so any calculation of your text position or lines will be taking the coordinate of the point and just replacing a dimension with the position of the respective plane.

To convert your plane coordinates in 3D to 2D positions for an OnGUI call to draw your text (for example) - you would use Camera.WorldToScreenPoint on Camera.main (the currently active camera). This will give you the pixel location of your impact points.

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 whydoidoit · Sep 09, 2012 at 10:03 AM 0
Share

You can make dotted lines by using a transparent material and a suitable texture.

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

raycast hit to relative location on collider? 1 Answer

How to hit two object with one raycast? 2 Answers

How to hit two objects with only one shot (raycast) 0 Answers

World scale of BoxCollider for Raycast and scale 1 Answer

how to check if 1 sided plane is facing the camera 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