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 Grieve_physics · Jan 01, 2014 at 05:46 AM · raycastenemyselect

Select Enemies(Raycast) -> Display Child Quad with circle base

I have been able to select enemies with the below raycast script, however when each enemy is selected, I want to give the user feedback which enemy is selected. (i.e. a Ring around the base of the enemy) I have been unable to create, find a solution, so asking for help / ideas to keep me going.

Currently I believe that enabling the mesh renderer on the quad will be the easiest way to do this, but I am disabling the parents renderer instead of the quad Child.

 function Update() 
 {
     if (Input.GetMouseButtonDown(1)) //Right CLick
     {
         var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
         var hit : RaycastHit;
         if (Physics.Raycast (ray, hit, 100)) 
         {
             Debug.DrawLine (ray.origin, hit.point);
             Debug.Log (hit.collider.gameObject.name);
             
             var es = hit.collider.gameObject.GetComponentInChildren(MeshRenderer);
             es.enabled = false;
             
 
         }
     }
 }

If you think there is a better way to do this, please let me know, or point me in the right direction.

Image of Quad Location Setup (As a Child under the Cube GameObject) alt text

circlequadsetup.jpg (47.6 kB)
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
0
Best Answer

Answer by HappyMoo · Jan 01, 2014 at 07:11 AM

So you have selection quads on every unit? No need - just have one selection object that you hide/show and move around.

 // show
 selector.transform.position = hit.collider.gameObject.transform.position;
 selector.setActive(true);
 
 // later hide
 selector.setActive(false);
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 Grieve_physics · Jan 01, 2014 at 07:37 AM 0
Share

Cheers Happy$$anonymous$$oo,

Worked perfectly... and love the simplicity :)

Thanks again

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

19 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

Related Questions

2d raycast enemy detection problem. 0 Answers

How to Stop Enemy "Shooting Through A Wall" 1 Answer

spherecast wont work 2 Answers

if you've selected this enum. do this. How? 1 Answer

Select instantiated object with mouse 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