shrinking charactor script help please...
so im toying around with animations, and i want my First person capsule to shrink, i created an animation for that... i want to play the animation when i press "q". and when i press "e" i want to go back to normal size...i only know basic java script can someone help me please??? i dont know how to assign buttons to a function...
i know it has to do with bools, trigger, or whatever, i think... please help
Answer by Zoogyburger · Feb 18, 2016 at 10:17 PM
Have a look at this: http://docs.unity3d.com/Documentation/ScriptReference/Animation.Play.html http://docs.unity3d.com/Documentation/ScriptReference/Animation.html
Here's an example:
function Update()
{
if(Input.GetKeyDown("q"))
{
// Plays the animation
animation.Play("Animation Name ");
}
}
wow, i didnt think it was that simple.. Thank you so much.
Hey, @Gatling Hawk youtube, I'm glad I could help! Please accept my answer by clicking the check-mark icon!
also, quick question, where do i apply the script?
also, quick question, where do i apply the script?
Sorry for the prolonged reply. You put the lines of code into the Player script or on any other object that you want to animate when you press the button!
ok ill try that. its ok about the prolonged thing. everyones got something to do
is there a way to play an audio clip i have when i shrink?
http://docs.unity3d.com/ScriptReference/AudioSource.Play.html
Something like this:
var soundFile : AudioClip;
function Update() {
if (Input.Get$$anonymous$$eyDown("q")) {
audio.clip = soundFile;
audio.Play();
}
}
Your answer
Follow this Question
Related Questions
Player(Cube) shrinks on KeyCode.F and back to original scale 2 Answers
Question about reduce file size when creating sprite(2D) animations 1 Answer
duplicate enemies animations wont work? 0 Answers
Animation window not showing current gameobject animations 0 Answers
Best practice to handle mirrored body hit animations? 1 Answer