Animation flashlight when run

Hi guys, i want to know how i can make an animation and when i press shift for run the flashlight turn down, when i unpress shift the flashlight come up again

like all fps games…

Thanks a lot

You can have the flashlight down on the animation (or make it parent to the hand bone) like:

flashlight.parent = handBone;

Or you can do the weird way and store the default flashlight rotation on a quaternion and on another store the value for running, and when the user press Shift, navigate from first value to second using Quaternion.lerp

//On variables definition

Quaternion startRotation;
Quaternion runningRotation;

float changeTime;


//On Start Run function:
running = true;
changeTime = Time.time

//On Stop Running function
running = false;
changeTime = Time.time;

//On Update Method 
   if(Time.time < changeTime + 1){
      flashlight.rotation = Quaternion.lerp(startRotation,runningRotation,Time.time - changeTime);
      flashlight.rotation = runningRotation;
   if(Time.time < changeTime + 1){
      flashlight.rotation = Quaternion.lerp(runningRotation,startRotation,Time.time - changeTime);
      flashlight.rotation = startRotation;

Add a spot light to your character. Enable/disable it at the shift key press.

You answered your own question - to make an animation where the flashlight points at the ground while you are running you need to make an animation where the flashlight points at the ground.

If you had an animated character with a run animation all you have to do to accomplish this is attach the light GameObject to the gun GameObject and it will always point where the gun points.

If you are looking for a recommendation for an animation program, I would recommend Cinema 4D - it is easy to learn the basics and it has a free trial that allows saving and exporting.

The best way to learn animation is to look up some tutorials, follow along with them, and once you feel like you have a basic understanding of how to use the program start trying to make your own creations without a tutorial.

soulblade has very kindly donated their script :

There are many many answers to that on this 'site alone :