laser effect on mouse click
hello, i am new to unity. this is my current update code. currently i am moving the camera according to mouse movements. and left click means zoom mode (from now on, mouse movements will zoom in/out) now i want right click to mean that i am pointing a laser to whereever i click on an object. i created an empty gameobject which is a child of my camera and named "laser". i created a linerenderer for it. i attached this script. and i thought that just making it active/non-active on click would do it. nothing happens though.
if (Input.GetMouseButtonDown(0))
{
zoomMode = !zoomMode;
}
if (Input.GetMouseButtonDown(1))
{
laser.SetActive(!active);
}
if (zoomMode == true)
{
if (Input.GetAxis("Mouse X") < 0)
{
cam.fieldOfView -= zoomSpeed / 8;
if (cam.fieldOfView < minZoom)
{
cam.fieldOfView = minZoom;
}
}
if (Input.GetAxis("Mouse X") > 0)
{
cam.fieldOfView += zoomSpeed / 8;
if (cam.fieldOfView > maxZoom)
{
cam.fieldOfView = maxZoom;
}
}
}
else
{
currentX += Input.GetAxis("Mouse Y") * sensitivityY;
currentY -= Input.GetAxis("Mouse X") * sensitivityX;
}
Your answer
Follow this Question
Related Questions
Bloom effect makes some weird flashes when the character moves 0 Answers
The laser problems 0 Answers
Raycast Troubleshooting 1 Answer
Line renderer over UI 0 Answers
Drawing a line perpendicular to a line on a plane whose normal is known 1 Answer