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 chef_seppel · May 18, 2015 at 01:19 PM · overlapcrosshairhighlight

How to highlight certain gameObjects in an screenarea

I have a 3d scene with obstacles and enemies (tagged as enemy). I also have a round crosshair of a diameter of 100 pixels which represents the spread of my gun. The crosshair follows the mousecursor while the camera is fixed. What i now want, is to highlight (color) the crosshair area which overlap an enemy when the enemy is not occluded by other objects in the scene. What is the best approach?

Additionally it would be really nice to calculate the percentage of enemy-area under the crosshair (aka the hitchance)

Thanks for any advice

Comment
Add comment · Show 7
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 barbe63 · May 18, 2015 at 01:52 PM 0
Share

Lots of stuff to do.

You first need a shader that suit your needs, maybe a toon shader outline with a red color for the outline can be enough.

Then you need to raycast trough walls (layermasks can help) and when it hit enemy change his shader to the outlined with a coroutine inside the enemy script. The coroutine have to stop itself after a while and put the original shader when you are not calling it again (check with booleans if coroutine is running in order to not run it multiple times)

Edit: about the inocclusion thing you probably have to set the walls alpha you hit with a RaycastAll

Good luck!

avatar image chef_seppel · May 18, 2015 at 02:12 PM 0
Share

Oh, i think i was a little misleading in the occluded explanation. Of course i only want to mark the areas of the enemy that are not occluded by other Objects. So i want to mark the parts of the enemy that can actually be seen.

avatar image barbe63 · May 18, 2015 at 02:20 PM 0
Share

Oh, then just change the enemy shader as I said. If the rest of the body is not to be seen who cares the shader it's having ;)

avatar image chef_seppel · May 18, 2015 at 05:07 PM 0
Share

i do, because the cam im talking about is just the secondary "action cam" :)

avatar image chef_seppel · May 18, 2015 at 05:14 PM 0
Share

i still dont understand your shader approach. Even if there where only one cam. Who gets the shader? The enemy or the Crosshair? And what kind of shader? Can you elaborate your answer a little more, please? :)

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Issue with clicking with a crosshair while using Oculus Rift 1 Answer

My crosshair is moving the opposite of the mouse position. Why? 1 Answer

Getting Bounding box from a collider with children 1 Answer

Question about letting the user choose 2 buttons and highlight them 0 Answers

Keep gameobject highlighted until another gameobject is selected (multiple gameobjects) 2 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