Question by 
               KUFgoddess · Feb 06, 2018 at 03:33 PM · 
                lightingmousemouse position  
              
 
              how to make flashlight follow mouse pointer in 2D?
Hello I was wondering how can i have this light follow my mouse pointer in a 2D project? so as you move the cursor the light would follow
 
                 
                opera-2018-02-06-09-32-39.png 
                (53.7 kB) 
               
 
              
               Comment
              
 
               
              I've been doing some research, but cannot find something similar only for game objects.
 
               Best Answer 
              
 
              Answer by KUFgoddess · Feb 06, 2018 at 04:02 PM
Found an answer http://www.lucedigitale.com/blog/unity-object-follow-cursor-pointer/ messed around with it and added a late update and converted to C#
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class LightFollowMouse : MonoBehaviour {
 
 
 
   
     public float depth = 10.0f;
     void LateUpdate()
     {
         FollowMousePosition();
     }
 
     void FollowMousePosition()
     {
         var mousePos = Input.mousePosition;
         var wantedPos = Camera.main.ScreenToWorldPoint( new Vector3(mousePos.x, mousePos.y, depth)); //you need a new vector3 because of the variables it takes XYZ Z= depth
         transform.position = wantedPos;
     }
     
    
 }
 
 
 
              Your answer
 
             Follow this Question
Related Questions
Rounding position with mouse constant update 1 Answer
How to control global mouse 0 Answers
,Know if the mouse position has changed 0 Answers
Light Arount mouse Cursor 1 Answer
How to Instantiate from mouse pos? 0 Answers