- Home /
Mouse controlled Laserpointer
I have developed a simple multiplayer FPS app. I have used the scripts Perframe Raycast, Laser scope and Laser Pointer from Angry Bots to give the characters a laser pointer to paint objects so that other users can see what they are looking at.
I would like to control the pointer so that it is only visible when the user presses his mouse button. Try as I might I cannot seem achieve this. I have tried inserting a
if (Input.GetMouseButtonDown(0))
command at various points in the scripts (mainly at start of raycast routines) but the best I have achieved is for the pointer to be off at start and then after one mouseclick permanently on.
Can anyone help?
What's wrong with
if(Input.Get$$anonymous$$ouseButton(0))
{
// draw the laser!
}
? There are several different forms of the 'Input.Get$$anonymous$$ouse', and I don't think you want the one that only activates for one frame.
Answer by Alverndbl · Jan 10, 2012 at 02:07 PM
Probably if(Input.GetMouseButtonDown(0)) is better since it returns True while the user presses the button. Also depending on the script you used you might just want to enable or disable the component with Behaviour.enabled
Your answer
Follow this Question
Related Questions
Creating a Ray Gun 1 Answer
Mouse Click + Raycast + Colliders 2 Answers
2D - Overlaying Colliders - MouseDown not detected 0 Answers
3D Space Shooter Firing Projectiles 0 Answers
Vector3.Reflect - wrong direction 5 Answers