- Home /
Question by
Hzb_User58 · Oct 26, 2018 at 03:58 PM ·
mousedrag
How can I change the light SpotAngle by rotating the cube?
the cube rotates with the mouse, now the light-Spot-Angle be reduced or enlarged at a certain y-position of the cube. Here is my previous code:
float RotationSpeedOfAMouse = 10;
public Light lt;
public GameObject Cube;
public void OnMouseDrag()
{
float x = Input.GetAxis("Mouse X") * RotationSpeedOfAMouse * Mathf.Deg2Rad;
Cube.transform.RotateAround(Vector3.up, x);
if (Cube.transform.rotation.eulerAngles.y == 50)
{
lt.spotAngle = 50;
}
}
Comment
Your answer

Follow this Question
Related Questions
Why my app bug when I test on mobile? 2 Answers
Drag GameObject with Mouse 1 Answer
Making a arrow instead of Linerenderer 2 Answers
Need help in drraging code? 1 Answer
OnMouseDrag, how to make the object not move on the Y axis 1 Answer