Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
0
Question by galshal · Jun 09, 2015 at 07:11 AM · mathlinerendererradar

radar orthogonal line to plane

hi guys I've created a radar my self, for a spaceship simulator that I have created

the Radar was created from 4 gameobjects: 1. radar - sphere (parent) 2. center - plane 4. centerPoint - small sphere that indicates point 0,0,0 in the radar (sphaceship location in the radar) 5. enemies points - list of small spheres that represents the enemies

Im trying to streach a line from the enemies points to the center plane that indicates the object relative height (relative to the spaceship because its space) but so far without success

any help will be appreciated

thanks in advance

Gal

Comment
Add comment · Show 2
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 HarshadK · Jun 09, 2015 at 07:28 AM 0
Share

Can you share an image or something that will make clear as to what you have achieved currently and what you want?

I think what you can do is draw a line using LineRenderer that takes two points - one is the enemy sphere's position and another is point on the center plane (the position of plane itself?).

avatar image galshal · Jun 09, 2015 at 08:13 AM 0
Share

alt text

the thing is Im trying to draw an orthogonal line from the dots to the plane (not the spaceship)

I have tryid to use line renderer and i think this is the right way but how do i find the second edge of the line (the one on the plane)

radar.png (151.0 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by HarshadK · Jun 09, 2015 at 09:48 AM

If your plane is always going to be perpendicular to the world Y axis then you can just perform a Raycast from the position of enemy ship sphere in world y axis direction. Now where this raycast intersets your plane will be the point on the plane is your second point. Now you can draw a line using Line Renderer with first point being the position of enemy ship sphere and second point we calculated above.

If your plane is not always perpendicular to the world Y axis then you would need to use Vector Projection to calculate this second point on the plane to draw the line.

Comment
Add comment · Show 4 · 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 galshal · Jun 09, 2015 at 10:06 AM 0
Share

is there a tool in unity that helps me calculate the vector projection?

avatar image HarshadK · Jun 09, 2015 at 12:14 PM 0
Share

No there is no direct method that will provide you with vector project. But there is just another way you can do it. Just find out the normal of the plane (up direction of transform in this case will do the trick). Now perform a raycast towards the plane and where this raycast hits the plane is your second point. Below is the test code for the same. You just have to make necessary changes to as per your structure and replace the Debug.DrawLine method with drawing the line with a Line Renderer. For this current code to work it has to be attached to the plane since it takes the transform of plane directly to work things out.

 // The transform of your enemy spaceship
 public Transform enemy;
 
 void Update () {
     
     // Get the up direction of transform and decide the direction based off the position of plane with respect to the enemy ship
     Vector3 dir = (transform.position.y < enemy.position.y) ? (-transform.up) : transform.up;
     
     RaycastHit hit;
     if(Physics.Raycast(enemy.position, dir, out hit))
     {
         // Draw the line between enemy ship position and hit point.
         Debug.DrawLine(enemy.position, hit.point, Color.green, 0.1f);
     }
 }
avatar image galshal · Jun 09, 2015 at 01:16 PM 1
Share

thanks alot man

lots of respect

avatar image HarshadK · Jun 09, 2015 at 01:37 PM 0
Share

Happy to help. :-)

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

20 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

Related Questions

Radar script help 2 Answers

How to make a wavy circle? 0 Answers

How do I make a particle system follow a function? 1 Answer

Creating a parabola line in 3D Space 1 Answer

How to calculate inner vertices of a line renderer? (math question) 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