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 Dreave · Nov 03, 2011 at 08:40 PM · guncollidedotred

Show Red Dot Where Ever The Gun Is Pointing?

How would I go about making a red dot appear where ever my gun is pointing? I don't mean a red line going on and on until it collides with something, I mean just where ever the gun is pointing the closest thing in front of the gun it shows the red dot on it.

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

5 Replies

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

Answer by Yoerick · Nov 04, 2011 at 07:41 AM

I found another, easier, way to create a red dot which I didn't think of yesterday. You could use a very narrow, red spotlight with a very high range and intensity. Just set the spot angle to 1 and the intensity to 8, this creates the effect of a red laserdot :)

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 Dreave · Nov 04, 2011 at 05:03 PM 0
Share

wow thanks

avatar image
0

Answer by Yoerick · Nov 03, 2011 at 08:45 PM

Maybe you could perform a raycast from the gun and instantiate a projector in front of the first object it hits, projecting a red dot on it? Can't try it out at the moment, but it's the first way I would think of when trying something like this.

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 Dreave · Nov 03, 2011 at 09:18 PM 0
Share

I am using a raycast for my bullets does this inter fear with your answer?

avatar image Yoerick · Nov 03, 2011 at 09:48 PM 0
Share

well the bullets could indeed interfere with a ray you cast from the gun, but on real guns, the laser (which makes the red dot) is located on one of the sides of the gun. You could make a new raycast at a position slightly next to your gun to avoid it from hitting the bullets, or you could place the bullet frefab in the "IgnoreRaycast" layer, this way they don't interfere anymore.

Anyway I think initiating a projector with a red dot material in front of the first object is the way to go and to know this first object you need a raycast. With a raycast you can also set a maximum range, which makes it realistic since real lasers have a maximum range as well.

avatar image Yoerick · Nov 03, 2011 at 10:00 PM 0
Share

Btw, to know the exact position of where the raycast hits the first object, use RaycastHit.point. Then you want to make a vector pointing from the gun transform to the RaycastHit.point position. With this vector you can instatiate your projector.

A tip when using the projector, make sure your texture is set to "clamp", otherwise your red dot will be repeated and you only need one.

avatar image CHPedersen · Nov 04, 2011 at 09:54 AM 0
Share

The projector solution is what I'd do too. Don't worry about the bullets getting in the way, you can set them to ignore the projector.

avatar image
0

Answer by Totalywicked · Nov 03, 2011 at 09:56 PM

You can use raycast, and then just create a red dot when it hits Something like this

 var hit : RaycastHit;
 if ( Physics.Raycast( Gun.transform.position, Gun.transform.forward, hit ) ) {
 Instantiate( RedDotPrefab, hit.point, Quaternion.LookRotation( hit.normal ) );
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 CHPedersen · Nov 04, 2011 at 09:52 AM 0
Share

This is no good, since the instantiated dot is stationary. He needs something that tracks the movement of the gun; a laser pointer.

avatar image
0

Answer by susanawalkly · Oct 31, 2012 at 10:20 AM

Does the red dot sight means a "red dot laser sight"? A red dot laser sight is able to project an extremely bright red dot on shooting targets.

Comment
Add comment · 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
0

Answer by ajaybhojani · Sep 25, 2015 at 12:07 PM

thanks for spotlight suggestion works fine after changing its texture

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

Animation & Script Help 2 Answers

RayCast Shooting not working 0 Answers

Rotation/position question. 1 Answer

Aiming down a gun 4 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