- Home /
 
 
               Question by 
               DoctorSauce · Jul 26, 2013 at 05:16 PM · 
                2dlightingcursorflashlight  
              
 
              How to aim the flashlight with the mouse in a 2d game?
I am working on a 2D platformer-ish game and I want to be able to move the mouse and have the spotlight follow the mouse so the player can control which direction the flashlight is pointing. I've been trying to figure it out for the last 2 days but I still have no idea where to start. Does anybody know how to do this?
Edit:
Maybe I should have included my script, even though all it does is turn off the flashlight. I don't know what I'm doing wrong.
 var mousePos : Vector3;
 
 function Start () {
     mousePos = Input.mousePosition;
 }
 
 function Update () {
     transform.rotation = Quaternion.LookRotation(mousePos);
 }
 
              
               Comment
              
 
               
              Your answer