How To Make Animation Play On Key Press Roblox Studio
- Spaces
- Default
- Help Room
- META
- Moderators
-
- Topics
- Questions
- Users
- Badges
- Habitation /
2
how to brand a animation play only if y'all printing a sure primal?
I have a ak 47 gun model with an reloading blitheness. I dont want the reloading animaation to first right when i kickoff playing my game. I but want my gun to kickoff reloading when i press the cardinal "r". How do i do this? Do I demand some sort of script or something?
eight Replies
· Add your reply
- Sort:
4
Answer by Jesus_Freak · Oct 24, 2010 at 04:57 PM
well, a script would work, it would be something like:
function Update() { if(Input.GetKeyDown("r")) { // Plays the reload animation - stops all other animations animation.Play("reload", PlayMode.StopAll); } }
just so you know, you lot take to rename the "reload" blitheness to whatsoever y'all chosen it.
hope this helps.
one
Reply past sam 1 · Nov 07, 2010 at 04:27 PM
well guys this is what i did. i fabricated the script and made a new input. I made a new javascript, called "reload", and copyed and pasted that script you lot gave me into it. And so copyed that script into my gun item thing. currently its in the hierarchy. my gun is as well called "reload". i tried information technology and it didnt work. it kept proverb: "the animtaion state reload could not be played considering it couldnt be found!" so i tried the iput thing. i made a new input called reload. i put the postive key equally "r". i tried it again and it didnt work. information technology said the same thing. "the animtaion state reload could not be played because information technology couldnt exist found!" whats wrong? why cant information technology play information technology? why does information technology go on maxim that? could some one help me?
one
Answer by Dummy7307 · February 04, 2011 at 03:25 PM
Do as Unity3_User says but change (Input.GetKeyDown) to (Input.GetButtonDown)
1
Reply past joe_coronado · February 01, 2012 at 09:12 PM
This happened to me it was considering the animation name had a capital letter ' R'and the "reload" in the script doesnt. then cheque your capitals, this reply is for sam
1
Answer by DevDale · Mar 03, 2012 at x:37 PM
How tin can I brand this same affect apply for when I press a mouse push?
For left mouse push: if (Input.Get$$bearding$$ouseButtonDown(0)) {
For correct mouse button: if (Input.Get$$anonymous$$ouseButtonDown(one)) {
For middle mouse push: if (Input.Get$$anonymous$$ouseButtonDown(2)) {
There you lot go, $$anonymous$$lep
- 1
- 2
- ›
Your answer
Welcome to Unity Answers
The all-time identify to ask and respond questions most evolution with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more than information.
Make sure to bank check out our Knowledge Base of operations for commonly asked Unity questions.
If you lot are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Follow this Question
Related Questions
Source: https://answers.unity.com/questions/31335/how-to-make-a-animation-play-only-if-you-press-a-c.html
Posted by: nguyencreformen.blogspot.com
only become to Edit --> Projection Settings --> Input, define the "r" key or whatsoever key you want and combine that with the answer above. You should accept smooth sailing from there
really, Go$$anonymous$$eyDown becomes true whenever yous printing downward on the keyboard key that yous define, i gave you the r key, so when you printing r, and if you set up the variables, the reload blitheness should play. what Proclyon said would work with the GetButtonDown statement. but you don't Accept to practise that with the Get$$anonymous$$eyDown argument.
tin can u please say how to put the variables and where, cuz this doesn't work, thank you =)