- Home /
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 need to be more specific. What is it that you want to know / are having problems with? Input? Animations? Lighting?
Answer by victorafael.com · Oct 05, 2012 at 12:03 AM
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(running){
if(Time.time < changeTime + 1){
flashlight.rotation = Quaternion.lerp(startRotation,runningRotation,Time.time - changeTime);
}else{
flashlight.rotation = runningRotation;
}
}else{
if(Time.time < changeTime + 1){
flashlight.rotation = Quaternion.lerp(runningRotation,startRotation,Time.time - changeTime);
}else{
flashlight.rotation = startRotation;
}
}
Answer by hvilela · Oct 04, 2012 at 09:14 PM
Add a spot light to your character. Enable/disable it at the shift key press.
Answer by MibZ · Oct 04, 2012 at 09:33 PM
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.
Answer by AlucardJay · Oct 05, 2012 at 03:53 AM
soulblade has very kindly donated their script :
http://answers.unity3d.com/questions/323129/if-anyones-looking-for-a-flashlight-script-with-a.html
There are many many answers to that on this 'site alone :
Your answer
Follow this Question
Related Questions
How to make Flashlight timer. 1 Answer
Trying to simply play this animation... Help please. 1 Answer
Reacting to Mouse animation... 2 Answers
Loop animation on button hold 2 Answers