- Home /
Best Answer
Answer by Narv · Dec 07, 2013 at 05:26 PM
I assume you want the spotlight to follow your mouse cursor on the floor or ground, correct? if so, look up the function ScreenPointToRay() in Camera.. also Physics.Raycast. You will get a ray from ScreenPointToRay and then do a raycast and find the RaycastHit point and then that would be the point in world space that the spotlight would shine .
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit;
if(Physics.Raycast(ray, out hit) { // make the spotlight do whatever using hit.point }
Your answer
![](https://koobas.hobune.stream/wayback/20220613123626im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Light Toggle 1 Answer
Light Cookie problem 1 Answer
Light Penetrating Fog 1 Answer
Spotlight lights up trees not in view 1 Answer
Flashlight battery script 3 Answers