- Home /
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.
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 :)
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.
I am using a raycast for my bullets does this inter fear with your answer?
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.
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.
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.
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 ) );
This is no good, since the instantiated dot is stationary. He needs something that tracks the movement of the gun; a laser pointer.
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.
Answer by ajaybhojani · Sep 25, 2015 at 12:07 PM
thanks for spotlight suggestion works fine after changing its texture
Your answer
Follow this Question
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