Unity3D - Trigger animations (keypress trigger)

  Рет қаралды 161,958

CubicBrain

CubicBrain

Күн бұрын

Пікірлер: 312
@CubicBrain
@CubicBrain 6 жыл бұрын
using UnityEngine; using System.Collections; public class animController : MonoBehaviour { public Animator anim; // Use this for initialization void Start () { anim = GetComponent(); } // Update is called once per frame void Update () { if (Input.GetKeyDown("1")) { anim.Play("cubeAnimation"); } if (Input.GetKeyDown("1")) { anim.Play("New cube Animation"); } } }
@spencer7985
@spencer7985 6 жыл бұрын
What is the second if? the New cube Animation?
@praveenvinopv9929
@praveenvinopv9929 6 жыл бұрын
@@spencer7985 The second if statement is when we press 1 again it start play new cube animation in this case it is idle animation by this way we can start or stop animation
@apersonthatsucksatnames1133
@apersonthatsucksatnames1133 6 жыл бұрын
how do you make it stop when you let go?
@iamthewankerpants
@iamthewankerpants 6 жыл бұрын
@@apersonthatsucksatnames1133 Asking the real questions here
@dz_apollo
@dz_apollo 5 жыл бұрын
@@iamthewankerpants if (Input.GetKeyUp("1"))
@jakeshuman2102
@jakeshuman2102 7 жыл бұрын
literally an hour of forum reading didn't produce the quality of information this 6 minute video gave.
@CubicBrain
@CubicBrain 7 жыл бұрын
Thank you very much Jake. I really appreciate it.
@bevel1702
@bevel1702 6 жыл бұрын
Same!
@AGeekNamedRoss
@AGeekNamedRoss 6 жыл бұрын
Guessing... Udacity forum?
@MrCornerMan
@MrCornerMan 6 жыл бұрын
ikr i was searching forever before i found this
@IvyTeaRN
@IvyTeaRN 5 жыл бұрын
literally the same thing
@mindonwarp
@mindonwarp 5 жыл бұрын
As simple as I needed it. Thank you! For all of you looking for a way to play the animation only once and go back to the initial state: just go to the animation editor UI ("Animator" tab), right click on your triggered animation node and choose "Make transition". An arrow coming out of the node will show up. Just pull this arrow onto your initial/idle state node and that should do it (did for me).
@M4SKD
@M4SKD 4 жыл бұрын
THANK YOU SO MUCH IVE BEEN TRYING TO WORK OUT HOW TO DO THIS FOR AGES :)
@JohnJohnson-ox3bu
@JohnJohnson-ox3bu 3 жыл бұрын
Thanks dude
@jenniferlight5050
@jenniferlight5050 Жыл бұрын
thank you sir!! You have saved my life. This was like attemp 50 of trying to get my door to open.
@xExplodingStarx
@xExplodingStarx 7 жыл бұрын
thank you for being so clear and to the point, really needed that.
@CubicBrain
@CubicBrain 7 жыл бұрын
Thanks a lot!
@sergioborrallo7424
@sergioborrallo7424 4 жыл бұрын
I checked your profile, I see that you don't make videos anymore. I really regret it, I think you explain extremely well. Thank you for your effort and time!
@brealz5351
@brealz5351 7 жыл бұрын
Incredible.. Fast and to the point, great tutorial !
@CubicBrain
@CubicBrain 7 жыл бұрын
Thanks a lot!
@gabrielbuchala7798
@gabrielbuchala7798 7 жыл бұрын
The key to a good tutorial is to communicate in a clean, precise and efficient way. This video hit the nail on the god damn head. I'm sure this video is going to help a lot of people, keep up the good work.
@CubicBrain
@CubicBrain 7 жыл бұрын
Thank you so very much. I really appreciate your comment. Its comments like these that really give me the drive to continue making these tutorials.
@r0y1t07
@r0y1t07 4 жыл бұрын
I like videos like this, no longer than 10 minutes and direct to the point :)
@xeon5259
@xeon5259 3 жыл бұрын
this is a very outdated tutorial, but still works for me, thanks to your easy,simple, to the point explanation. ThankYou!
@007walk
@007walk 6 жыл бұрын
Thanks for this. This is a much simple way of implementing what i wanted. For some reason my animation kept transitioning to the previous state with when using the trigger, but this just saved me a bunch of time. Thanks again.
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Rodane, thanks for your feedback, I'm glad you liked it.
@tristunalekzander5608
@tristunalekzander5608 4 жыл бұрын
After several minutes of searching, this was exactly what I needed, thank you!
@oofusmcdoofus
@oofusmcdoofus 4 жыл бұрын
Me too
@ligrens
@ligrens 4 жыл бұрын
Several hours you mean.
@Itay_Ron
@Itay_Ron 4 жыл бұрын
Thank you! after 4 years I could not find a better guide!
@ZekaProf
@ZekaProf 5 жыл бұрын
well i was trying for ages to get my main menu animation to work with overwhelming solutions but yours was the simpliest and the most precise
@СтепанЛутошкин-о8ю
@СтепанЛутошкин-о8ю 4 жыл бұрын
You are the best! I was looking for the solution for 4 hours! Thank you so much!
@kristophia7310
@kristophia7310 4 жыл бұрын
i lost my sanity before i found him Psychological factors that may contribute to mental illness include: Severe psychological trauma suffered as a child, such as emotional, physical, or sexual abuse. An important early loss, such as the loss of a parent. Neglect. An important early loss, such as the loss of a parent. - button plays animation gone, Neglect. sources cant help i am only joking
@RUDERUDYTUTORIALS
@RUDERUDYTUTORIALS Жыл бұрын
Still helpful in 2023 thank you very much for your support.
@a-vena
@a-vena 3 жыл бұрын
Finaly i found this Tutorial. Thanks
@sbdesigns4999
@sbdesigns4999 6 жыл бұрын
Great! I had been looking for a really direct and simple example and here it is! Thank you :)
@oviroysarker8066
@oviroysarker8066 4 жыл бұрын
You have saved my unity carrier!!!!!
@clintstapleton2289
@clintstapleton2289 5 жыл бұрын
This is exactly what I needed thank you!
@darkhackerstudio8112
@darkhackerstudio8112 4 жыл бұрын
How do you make it so that when you release the key it stops the animation
@Zukomazi
@Zukomazi 5 жыл бұрын
Works like a charms Nice and simple
@ImGodz0
@ImGodz0 6 жыл бұрын
how can i stop an animation on releasing button and go back to idle animation in void update?
@RyanRioga
@RyanRioga 6 жыл бұрын
Anyone who might find an issue where the animation will not trigger, Add (KeyCode.1) (I used 'Q' for mine) to the code after GetKeyDown. Other than that, super helpful video! Checked a lot of forums and whatnot and found nothing helpful. Nice job dude.
@CubicBrain
@CubicBrain 6 жыл бұрын
Thank a lot, and good tip!
@modernistt
@modernistt 6 жыл бұрын
used for my gun game. Thanks very quick and straight to the point.
@aksovicdalibor998
@aksovicdalibor998 5 жыл бұрын
+CubicBrain Do you, by any chance, remember what key combo u did at 4:40, to jump right into Start function? Looks super useful for bigger projects.. Thanks for video, helped a lot.
@animeboy93
@animeboy93 6 жыл бұрын
I hope this one finally helps me with my animation troubles. Been trying to work this stuff out for days. I keep seeing videos where they set the Boolean or trigger and the animation just works.
@theotherone0101
@theotherone0101 7 жыл бұрын
how can i do it. if it just should play the animation 1 time ?
@CubicBrain
@CubicBrain 7 жыл бұрын
Click the animation in the project field, and uncheck "Loop time", in the Inspector.
@100percentpodcasts7
@100percentpodcasts7 7 жыл бұрын
Cheers
@official420er
@official420er 6 жыл бұрын
but after activating the animation once, i cant do it after that.. could this be solved?
@rajjaiswal1606
@rajjaiswal1606 6 жыл бұрын
Zuchini DE sorry for late reply but in update use the following code If(Input.GetKeyUp("1")) ( anim.play("name of animation") = false ) If not use this one If(Input.GetKeyUp("1")) ( anim.stop("name of animation") ) Or use this one by making another animation which has nothing transformed and write If(Input.GetKeyUp("1")) ( anim.play("name of animation1") )
@official420er
@official420er 6 жыл бұрын
thanks alot
@AstrusHD
@AstrusHD 5 жыл бұрын
Awesome Tutorial, it helped me so much. Thank you!
@RUDERUDYTUTORIALS
@RUDERUDYTUTORIALS Жыл бұрын
It's really helpful right.
@kapex6405
@kapex6405 3 жыл бұрын
Awesome tutorial have had trouble with this for like a year or so :D
@kapex6405
@kapex6405 3 жыл бұрын
Also this was super easy to customize
@leeli9243
@leeli9243 5 жыл бұрын
thank you very much! It's nice and easy to understand
@og_shrug
@og_shrug 4 жыл бұрын
Man this vid helped me get into a club (coding C# and unity) . Thnx
@TheRealArtDoctor
@TheRealArtDoctor 4 жыл бұрын
hey man i have one small issue the code error says aplay has no definiton
@alirazahaider7108
@alirazahaider7108 3 жыл бұрын
What if there were Different animations to be played on different objects then how will we be able to do that?
@AwsomeDragon
@AwsomeDragon 6 жыл бұрын
Excellent tutorial, thank you so so so so much!!
@kieronrana5233
@kieronrana5233 4 жыл бұрын
great video! straight to the point, literally that easy. thanks for your help :)
@tassodemo2316
@tassodemo2316 4 жыл бұрын
If you press it once, it goes forever. If you turn off the loop, it only plays once.
@garlicbread1575
@garlicbread1575 4 жыл бұрын
yes but how do you turn off the loop?
@AwsomeDragon
@AwsomeDragon 6 жыл бұрын
how can i stop the animation?
@stasiek0079
@stasiek0079 6 жыл бұрын
You need create new animation
@rahulpatil3333
@rahulpatil3333 6 жыл бұрын
this.GetComponent().stop();
@AwsomeDragon
@AwsomeDragon 6 жыл бұрын
rahul patil thank you 🙏
@shauryakumar306
@shauryakumar306 3 жыл бұрын
@CubicBrain Thanks you really showed me how it's done.
@BojanVasilev
@BojanVasilev 6 жыл бұрын
hello great tutorial but how can i make when i press again to animation stop and if i press again animation start again
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Bojan, You will have to set up an if statement, that looks for the animation state (which animation is currently playing.)
@jirahmarienavarro8701
@jirahmarienavarro8701 4 жыл бұрын
What if I just want it to rotate one time and it should disable any more movement?
@Yu0nes
@Yu0nes 6 жыл бұрын
Thank you man very good tutorial
@CubicBrain
@CubicBrain 6 жыл бұрын
Thank you very much.
@Normal_Norman
@Normal_Norman 6 жыл бұрын
Cheers, worked first time!
@tomcruz8615
@tomcruz8615 7 жыл бұрын
Quick question. What would you use to trigger two animations with the same key? (Sounds like a dumb question but i'm a unity newb so whatever).
@kaldogorath
@kaldogorath 7 жыл бұрын
I'm not sure if you can play two animations from the same controller (anim here) at the same time. Either way, you would simply call another thing in the if statement where the anim.Play(); is called already. so it would read like anim.Play("clip1"); anim.Play("clip2"); That is, if you can play two from the same one. If not, you'll need two animator controllers and would call anim1.Play and anim2.Play back to back in the if statement.
@tomcruz8615
@tomcruz8615 7 жыл бұрын
Nick Miller ohhh I'll try both of those out. Thank you for that
@Nikoplays0910
@Nikoplays0910 5 жыл бұрын
Thanks, now I can play the orange justice animation
@nibernator
@nibernator 6 жыл бұрын
For some reason I am getting an error: Invalid Layer Index '-1' I did everything exactly like the video, no dice...
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi, please double check your namings/case-sensitiviness for the animations etc. could you post your code?
@nibernator
@nibernator 6 жыл бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; // THIS SCRIPT NOT WORKING public class animController : MonoBehaviour { public Animator anim; // Use this for initialization void Start () { anim = GetComponent(); // caches controller at start. } // Update is called once per frame void Update () { // string reference //check for key press if (Input.GetKeyDown("1")) { print("Key Down"); // To test if input responds to key. anim.Play("cubeAnimation"); // Plays the animation asset named cubeAnimation. } } }
@nibernator
@nibernator 6 жыл бұрын
These are what the errors say, "Animator.GotoState: State could not be found UnityEngine.Animator:Play(String) animController:Update() (at Assets/animController.cs:22)" The other error: "Invalid Layer Index '-1' UnityEngine.Animator:Play(String) animController:Update() (at Assets/animController.cs:22)" Thanks for your time!
@CubicBrain
@CubicBrain 6 жыл бұрын
I'm thinking it could be one of two things. It might be that the animator hasn't been added to the field in the inspector, or that the naming of the specific animation state (the animation you want to play back) isn't correct?
@karanveermultani6594
@karanveermultani6594 4 жыл бұрын
I know this comment was a year back but I found out what was wrong. There is an extra if statement in the update. Remove the one that plays "New cube animation" and you won't get the error anymore. The code in the comments has this, so please do mind changing it.
@leongrigoruk
@leongrigoruk 6 жыл бұрын
One of the best
@CubicBrain
@CubicBrain 6 жыл бұрын
Thanks. appreciate it.
@Conmac
@Conmac 6 жыл бұрын
PLEASE HELP! I have a running animation and an idl animation, once i press 1 to trigger another animation, after its done none of the other animations work? Help
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Conmac. does any of your animation go to the exit state?
@Conmac
@Conmac 6 жыл бұрын
CubicBrain I have figured it out! But thanks for responding bro
@CubicBrain
@CubicBrain 6 жыл бұрын
okay, great.
@Dennis10Paulino
@Dennis10Paulino 7 жыл бұрын
Very simple and effective, thanks!
@CubicBrain
@CubicBrain 7 жыл бұрын
Thanks man!
@praveenvinopv9929
@praveenvinopv9929 6 жыл бұрын
Thank you brother you earned 1 subscribe i found many video regrading to this lesson but all the video was difficult and yours was just asweome keep it up and kindly keep us to know this kind of short tricks
@CubicBrain
@CubicBrain 6 жыл бұрын
Thanks a lot. will do.
@seddaouiyassine7814
@seddaouiyassine7814 6 жыл бұрын
How if we only want it to play 1 time?
@onatunlu5158
@onatunlu5158 6 жыл бұрын
Thanks dude It fixed my problems.
@fiQmeister
@fiQmeister 5 жыл бұрын
what if i want to be able to stop and start t again?
@icantth1nkofanam40
@icantth1nkofanam40 4 жыл бұрын
mine only works once then it doesnt trigger after that
@sanjaychowdappa6306
@sanjaychowdappa6306 5 жыл бұрын
Thanks a lot sir u have best solution
@jazminajelani8395
@jazminajelani8395 6 жыл бұрын
hye, i want to create a game where player will be given 2 button and if they click on wrong answer button there is animation will play and vice versa. but i dont know how to code the button to play the timeline because the animation is in the timeline. could u please help me?
@gabrielguitiánestrella
@gabrielguitiánestrella 6 жыл бұрын
succinct and precise, awesome!
@CubicBrain
@CubicBrain 5 жыл бұрын
thanks!
@vicuna4036
@vicuna4036 6 жыл бұрын
How can i let it play one time and it will automaticly go back to emphty state?
@310thebank
@310thebank 7 жыл бұрын
how about if we want our player collider with trigger box and play animation not press key button how we must change code
@alejandrozamora3468
@alejandrozamora3468 5 жыл бұрын
Thank you, very helpful
@asklapios
@asklapios 3 жыл бұрын
thank you so much about this training
@jasielt.2006
@jasielt.2006 4 жыл бұрын
hey i dont know if you can help me but whenever i press the button to do the animation it stays frozen at the end of the animation and dosent transform back to its orignal state and says Katana AnimationEvent has no function specified
@CubicBrain
@CubicBrain 4 жыл бұрын
Hi Jasiel, You can add a transition to an idle state in the animation, or make the animation loop. Animations are a bit like video playback, and will just stop at the last frame.
@emilyallen7912
@emilyallen7912 2 жыл бұрын
It won’t let me add a new state when I right click it just says add behavior
@haru_ne_
@haru_ne_ 4 жыл бұрын
I wanted to know how to use Trigger parameters but I figure it out anyway. Thanks.
@ruler1559
@ruler1559 5 жыл бұрын
say if I want to get back to the other animation, how do I do it?
@CubicBrain
@CubicBrain 5 жыл бұрын
If you just want it to go back automatically, right click the animation node that you trigger, and select make transition. then click back on the first animation node.
@iTapClashRoyale
@iTapClashRoyale 7 жыл бұрын
Why doesn't Visual Studio recognize "Animator"???
@samu-rai983
@samu-rai983 5 жыл бұрын
YEAAAAHH WHYYYYY THEE FFUUUUUCK NOOT
@ChuckyMaster
@ChuckyMaster 5 жыл бұрын
thank you bro really help ful
@joshuaheejd
@joshuaheejd 7 жыл бұрын
I need some help with double keypress trigger animations? Meaning when i press e.g X, 1 thing happens and then when i press Y another thing happens to the same model. Are there any tutorials on this?
@JacksonAcademy1
@JacksonAcademy1 7 жыл бұрын
Thank you~
@shaquielleemptage1888
@shaquielleemptage1888 7 жыл бұрын
How do I make it stop when I let go of the key
@CubicBrain
@CubicBrain 7 жыл бұрын
Hi, You should be able to make a new if statement where you look for keyUp. A bit like this: if (Input.GetKeyUp("1")){ anim.Play("New State");}
@rajjaiswal1606
@rajjaiswal1606 6 жыл бұрын
CubicBrain
@rajjaiswal1606
@rajjaiswal1606 6 жыл бұрын
CubicBrain why didn't you reply to zuichini DE's comment? I just answered him 3 ways
@bratish9290
@bratish9290 7 жыл бұрын
What about having more than one animation state? I can't find any information about this issue(
@historyofmistory7421
@historyofmistory7421 7 жыл бұрын
I have a Q why I can't scale my terrine when I use unity ?
@hal69420
@hal69420 6 жыл бұрын
How can I trigger it with OnTriggerEnter Please tell me.
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Zeyad, You have to set up a trigger-collider on the trigger (gameobject) of your choosing. then on that object in a script use the "OnTriggerEnter" function like: void OnTriggerEnter(Collider other) { //code you want to execute } as soon as another gameobject with a colliger enters your trigger collider, it should execute the code.
@rickfuzzy
@rickfuzzy 6 жыл бұрын
Excellent. Feel like i just leveled up
@CubicBrain
@CubicBrain 6 жыл бұрын
Awesome! happy that it helped you!
@bogdan_cx
@bogdan_cx 4 жыл бұрын
Thanks a lot man, you helped me so much!
@blzy2305
@blzy2305 7 жыл бұрын
How to make this with Left Pressed?
@camy_dev
@camy_dev 7 жыл бұрын
I really loved this thanks man I used it with a trigger to make a script to play when I'm in a trigger, but I was wondering how I specify in the script that i only want it to play once, in other words i have a dresser that moves when I press e near it but i only want you to be able to play this animation once otherwise you can move the same dresser over and over again any help would be appreciated thank you so much already though.
@CubicBrain
@CubicBrain 7 жыл бұрын
The simplest solution would be to set a transition within the animator, to either the exit state, or a new idle state.
@CubicBrain
@CubicBrain 7 жыл бұрын
you can also check the reply to ewwitsantonio question answered by xXpandatree12Xx10. He added a nice three step guide.
@camy_dev
@camy_dev 7 жыл бұрын
Thank you got it lol
@thecomedyduo4001
@thecomedyduo4001 4 жыл бұрын
how to I make the animation keep repeating until i let go of the key?(for walking)
@CubicBrain
@CubicBrain 4 жыл бұрын
you might be able to use Input.GetKeyUp to stop the animation
@grosbarbu5778
@grosbarbu5778 5 жыл бұрын
It's possible to do the same thing with the E key ? If yes how to do that ?
@CubicBrain
@CubicBrain 5 жыл бұрын
Hi Privelol, You should be able to just change the 1 inside the two double quotes to the desired letter.
@ミフヒヨ
@ミフヒヨ 7 жыл бұрын
soo i can direct animation like that using while for example walk while pressing w ?
@toddlertech8091
@toddlertech8091 7 жыл бұрын
great tutorial... Thanks
@CubicBrain
@CubicBrain 7 жыл бұрын
Thanks man!
@deryabwaseem3793
@deryabwaseem3793 6 жыл бұрын
how I rotate my object in the menu page in unity
@sakshamsahgal9420
@sakshamsahgal9420 6 жыл бұрын
can u plz tell me how to pause animation using this?
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Saksham, There is no straight forward way to do it (anim.Pause() will not work). You might want to look into stopping the time or setting the speed of your animation. There is a thread on the unity site that discusses this issue: answers.unity.com/questions/48077/pausing-an-animation.html
@anandpattar3106
@anandpattar3106 5 жыл бұрын
How to stop the animation?
@LeCigareVolant
@LeCigareVolant 6 жыл бұрын
Did you ever know that you're my hero? -Bette Midler
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi. Thanks a lot.
@FoxGAMING-NTF
@FoxGAMING-NTF 6 жыл бұрын
Just a quick question... How do I make the animation play only once?
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi, You can set an "Exit" on the animation. You have your animation that you start with. Normally that it would then just sit there stuck in that animation. However if you set a transition to exit or an empty animation it will only play once.
@FoxGAMING-NTF
@FoxGAMING-NTF 6 жыл бұрын
CubicBrain Thanks!
@FoxGAMING-NTF
@FoxGAMING-NTF 6 жыл бұрын
CubicBrain Also, I need help with something else. . . So, I'm making a horror game. There is a fridge that will contain clues. It has double doors. I want to add the animation to it. How would I make it so that when I am close to the doors (Each door has a box collider, and if the door rotates, the box collider rotates with it) another animation plays (aka the closing)? How could I switch the activator to be a left click (GetMouseDown;), right? And how could I make it so that When I left click, it Opens, and stays open, even when I walk away, and when I walk back into the box collider, how could I make it so that I have to click again to close it? Sorry for all of the questions, I hope they make sense and you can help me figure them out. I'm just desperate to get this done, and nothing else has helped...
@hyenagametalk7293
@hyenagametalk7293 7 жыл бұрын
how would I get I to stop when I release the button
@lucutes2936
@lucutes2936 4 жыл бұрын
how do I make them movable with WASD
@kkrazius
@kkrazius 6 жыл бұрын
Thank you, it worked just fine!
@jimmsdesign-freelancegraph1549
@jimmsdesign-freelancegraph1549 5 жыл бұрын
I was hoping you may be able to help. I followed your tut but tailored one or 2 bits but I'm getting this error - MissingComponentException: There is no 'Animator' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Animator to the game object "Player". Or your script needs to check if the component is attached before using it. - I have attached the script to both the player and the object but it still throwing back this error. Do you know what I could be doing wrong?
@joshuamason2227
@joshuamason2227 5 жыл бұрын
attach animator
@vlad-cristiansecatureanu6820
@vlad-cristiansecatureanu6820 5 жыл бұрын
I want to make it so that you can press the button multiple times a knob moves further like one step at a time. Is it posible to do it with only one animation, or do i need one for each step of the knob? pls reply
@CubicBrain
@CubicBrain 5 жыл бұрын
Hi, well you could play a part of the animation, but that setup would probably be a bit complex. if you create a bunch of takes/animation you could play them back and use basic if statement setup to see how far along the line you are. however if its simple movement you are going for. I would suggest just scripting the movement of the gameobject. this post might help you: answers.unity.com/questions/667641/how-do-i-move-my-2d-object-using-arrow-keys-also-h.html
@v3vlog
@v3vlog 6 жыл бұрын
hey I am not seeing empyt in animation controller
@Jaydanson
@Jaydanson 7 жыл бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; public class animcontroller : MonoBehaviour { public Animator anim; // Use this for initialization void Start () { anim = GetComponent(); } // Update is called once per frame void Update () { if (Input.GetMouseButtonDown("0")) anim.Play("ReadSwing01") } That's what the script is supposed to look like right? Because i keep getting errors
@CubicBrain
@CubicBrain 7 жыл бұрын
You need closing } for tour update method and class (two of them at the end of your script).
@HDMaco13
@HDMaco13 6 жыл бұрын
You need to remove the -> " " in if (Input.GetMouseButtonDown("0")) It should look like if (Input.GetMouseButtonDown(0))
@silvanacallegari
@silvanacallegari 7 жыл бұрын
you are AWESOME!
@CubicBrain
@CubicBrain 7 жыл бұрын
Thank a lot.
@redinternet9893
@redinternet9893 6 жыл бұрын
why my rotate animation is fast > slow > fast > slow (loop)
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi Ken, You need to select the keyframes in your animation, and set them to linear. this way the wont do bezier/easing animations.
@redinternet9893
@redinternet9893 6 жыл бұрын
where can set linear
@CubicBrain
@CubicBrain 6 жыл бұрын
In the "Animation" window, with your gameobject selected you should be able to see the Rotation (like in the video at 2:30). if you select the keyframes, and right click then, in the drop down menu you can change the "Tangents". if you choose "both tangents" and set them to "Linear", you animation should be smooth.
@ashoan8965
@ashoan8965 7 жыл бұрын
What about uh, this is for my car game... I want a door to open and stop on the press of a key, and if pressed a second time, it reverses, the door would close, like if the animation is reversed and stop like it did when opening the door. hood trunk it could be anything.
@drgitgud
@drgitgud 6 жыл бұрын
@CubicBrain hello i´ve googeled for like 2 days now but i cant find any answers so i may bother you ^^ im looking for an animation on an instantiated object, my problem is as i set the animation up (just going up on the y nothing more) it takes the x and z axes aswell and my onmouse instantiate doesnt work anymore. the object doesnt spawn where i click instead all the clones spawn at the set up x and z values. i want to make a spell where the player raises a wall from the ground kinda like earthbender styled but i cant get it to work. thank you so much in advance if you actually answer it would make my day :) peace
@CubicBrain
@CubicBrain 6 жыл бұрын
Hi, I'm not sure how you would achieve the functionality that you are looking for. but, have you tried posting on the Unity3D forums? They are always willing to help.
@drgitgud
@drgitgud 6 жыл бұрын
i had to place my wall into an empty gameobject to ignore its transform. my object was spawning right where animated it in the scene so it took the x and z values with it to avoid using them parent it. thanks :)
@juankacoolx0
@juankacoolx0 5 жыл бұрын
You are the best one
@berkaybakacak
@berkaybakacak 7 жыл бұрын
Thnaks dude. You are great :)
@CubicBrain
@CubicBrain 7 жыл бұрын
Thanks, glad you liked it.
@hazestorm1467
@hazestorm1467 5 жыл бұрын
idk if u here at all but i got a lil problem. so this code works great. but. i want the animation played once. so i turn off loop. but than i realize. i can only activate the animation once and not every time i press the key? help TT
@CubicBrain
@CubicBrain 5 жыл бұрын
Hi, if you make an empty animation in your animator, and set a transition to that state, the animation should play once, and can then be activated again.
@hazestorm1467
@hazestorm1467 5 жыл бұрын
@@CubicBrain thank you very much mate
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН
Unity Basics - Animation Events
7:58
MetalStorm Games
Рет қаралды 36 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
How to easily display text in unity by a trigger! c#
10:09
Notes From A Nomad
Рет қаралды 31 М.
A new way to generate worlds (stitched WFC)
10:51
Watt
Рет қаралды 555 М.
Make your Characters Interactive! - Animation Rigging in Unity
16:19
Inside the V3 Nazi Super Gun
19:52
Blue Paw Print
Рет қаралды 2,3 МЛН
Making a Game About Weak Points
21:27
Emis
Рет қаралды 893 М.
Playing Animation on Trigger in Unity
9:04
SpeedTutor
Рет қаралды 161 М.
Triggering Animations Using Unity XR Interaction Events
6:30
Ryan Murray
Рет қаралды 3,4 М.
10 Minutes vs. 10 Years of Animation
19:29
Isto Inc.
Рет қаралды 1,5 МЛН