We take a look at how to activate the animation on a simple unity cube.
Жүктеу.....
Пікірлер: 314
@CubicBrain5 жыл бұрын
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
5 жыл бұрын
What is the second if? the New cube Animation?
@praveenvinopv9929
5 жыл бұрын
@@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
5 жыл бұрын
how do you make it stop when you let go?
@iamthewankerpants
5 жыл бұрын
@@apersonthatsucksatnames1133 Asking the real questions here
@dz_apollo
5 жыл бұрын
@@iamthewankerpants if (Input.GetKeyUp("1"))
@jakeshuman21027 жыл бұрын
literally an hour of forum reading didn't produce the quality of information this 6 minute video gave.
@CubicBrain
6 жыл бұрын
Thank you very much Jake. I really appreciate it.
@bevel1702
6 жыл бұрын
Same!
@AGeekNamedRoss
6 жыл бұрын
Guessing... Udacity forum?
@MrCornerMan
6 жыл бұрын
ikr i was searching forever before i found this
@IvyTeaRN
5 жыл бұрын
literally the same thing
@mindonwarp4 жыл бұрын
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
4 жыл бұрын
THANK YOU SO MUCH IVE BEEN TRYING TO WORK OUT HOW TO DO THIS FOR AGES :)
@JohnJohnson-ox3bu
3 жыл бұрын
Thanks dude
@xExplodingStarx7 жыл бұрын
thank you for being so clear and to the point, really needed that.
@CubicBrain
7 жыл бұрын
Thanks a lot!
@brealz53517 жыл бұрын
Incredible.. Fast and to the point, great tutorial !
@CubicBrain
7 жыл бұрын
Thanks a lot!
@ZekaProf5 жыл бұрын
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
@r0y1t073 жыл бұрын
I like videos like this, no longer than 10 minutes and direct to the point :)
@gabrielbuchala77986 жыл бұрын
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
6 жыл бұрын
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.
@007walk6 жыл бұрын
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
6 жыл бұрын
Hi Rodane, thanks for your feedback, I'm glad you liked it.
@sbdesigns49995 жыл бұрын
Great! I had been looking for a really direct and simple example and here it is! Thank you :)
@itay78843 жыл бұрын
Thank you! after 4 years I could not find a better guide!
@clintstapleton22895 жыл бұрын
This is exactly what I needed thank you!
@sergioborrallo74243 жыл бұрын
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!
@tristunalekzander56084 жыл бұрын
After several minutes of searching, this was exactly what I needed, thank you!
@oofusmcdoofus
4 жыл бұрын
Me too
@rukasugaberu4792
4 жыл бұрын
Several hours you mean.
@jenniferlight5050 Жыл бұрын
thank you sir!! You have saved my life. This was like attemp 50 of trying to get my door to open.
@modernistt6 жыл бұрын
used for my gun game. Thanks very quick and straight to the point.
@kieronrana52334 жыл бұрын
great video! straight to the point, literally that easy. thanks for your help :)
@user-sp5ho7vy8l4 жыл бұрын
You are the best! I was looking for the solution for 4 hours! Thank you so much!
@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
@animeboy936 жыл бұрын
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.
@AwsomeDragon5 жыл бұрын
Excellent tutorial, thank you so so so so much!!
@AstrusHD4 жыл бұрын
Awesome Tutorial, it helped me so much. Thank you!
@RUDERUDYTUTORIALS
9 ай бұрын
It's really helpful right.
@Zukomazi5 жыл бұрын
Works like a charms Nice and simple
@onatunlu51586 жыл бұрын
Thanks dude It fixed my problems.
@RUDERUDYTUTORIALS9 ай бұрын
Still helpful in 2023 thank you very much for your support.
@Normal_Norman6 жыл бұрын
Cheers, worked first time!
@xeon52593 жыл бұрын
this is a very outdated tutorial, but still works for me, thanks to your easy,simple, to the point explanation. ThankYou!
@310thebank6 жыл бұрын
how about if we want our player collider with trigger box and play animation not press key button how we must change code
@leeli92435 жыл бұрын
thank you very much! It's nice and easy to understand
@Dennis10Paulino6 жыл бұрын
Very simple and effective, thanks!
@CubicBrain
6 жыл бұрын
Thanks man!
@joshuaheejd7 жыл бұрын
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?
@praveenvinopv99295 жыл бұрын
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
5 жыл бұрын
Thanks a lot. will do.
@oviroysarker80663 жыл бұрын
You have saved my unity carrier!!!!!
@derkenek78403 жыл бұрын
Finaly i found this Tutorial. Thanks
@shauryakumar3063 жыл бұрын
@CubicBrain Thanks you really showed me how it's done.
@kapex64052 жыл бұрын
Awesome tutorial have had trouble with this for like a year or so :D
@kapex6405
2 жыл бұрын
Also this was super easy to customize
@og_shrug3 жыл бұрын
Man this vid helped me get into a club (coding C# and unity) . Thnx
@BogdanAndreiRO3 жыл бұрын
Thanks a lot man, you helped me so much!
@ImGodz05 жыл бұрын
how can i stop an animation on releasing button and go back to idle animation in void update?
@user-vj2ek5pz9s7 жыл бұрын
soo i can direct animation like that using while for example walk while pressing w ?
@Yu0nes6 жыл бұрын
Thank you man very good tutorial
@CubicBrain
6 жыл бұрын
Thank you very much.
@jirahmarienavarro87013 жыл бұрын
What if I just want it to rotate one time and it should disable any more movement?
@Nikoplays09105 жыл бұрын
Thanks, now I can play the orange justice animation
@Skullcat22124 жыл бұрын
How can i trigger an animation when pressing a hud button?
@sanjaychowdappa63065 жыл бұрын
Thanks a lot sir u have best solution
@jazminajelani83955 жыл бұрын
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?
@bratish92907 жыл бұрын
What about having more than one animation state? I can't find any information about this issue(
@asklapios3 жыл бұрын
thank you so much about this training
@alirazahaider71082 жыл бұрын
What if there were Different animations to be played on different objects then how will we be able to do that?
@darkhackerstudio81124 жыл бұрын
How do you make it so that when you release the key it stops the animation
@alejandrozamora34685 жыл бұрын
Thank you, very helpful
@SavanaStudios7 жыл бұрын
Helped alot! Thanks!
@mehulsinghal41555 жыл бұрын
hey ! i m not able to do the second part of the video...like when i click one the cube isnt rotating Can anyone please help me regarding that i copied the exact same code
@marciux38834 жыл бұрын
can i make that after i pressed 1 animation starts and auto stops?
@aksovicdalibor9984 жыл бұрын
+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.
@Mr09shaggy6 жыл бұрын
Thanks for the video :)
@vicuna40365 жыл бұрын
How can i let it play one time and it will automaticly go back to emphty state?
@historyofmistory74216 жыл бұрын
I have a Q why I can't scale my terrine when I use unity ?
@haru_ne_3 жыл бұрын
I wanted to know how to use Trigger parameters but I figure it out anyway. Thanks.
@darkexior5 жыл бұрын
succinct and precise, awesome!
@CubicBrain
5 жыл бұрын
thanks!
@deryabwaseem37935 жыл бұрын
how I rotate my object in the menu page in unity
@RyanRioga5 жыл бұрын
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
5 жыл бұрын
Thank a lot, and good tip!
@Shardey6 жыл бұрын
Assets/animController.cs(19,19): error CS1502: The best overloaded method match for `UnityEngine.Input.GetMouseButtonDown(int)' has some invalid arguments
@TheRealArtDoctor3 жыл бұрын
hey man i have one small issue the code error says aplay has no definiton
@hyenagametalk72937 жыл бұрын
how would I get I to stop when I release the button
@hackersitoxd96894 жыл бұрын
GREAT TUTORIAL!
@fiQmeister4 жыл бұрын
what if i want to be able to stop and start t again?
@AzoozePvP4 жыл бұрын
Thanks Bro, but i have problem i use void OnTriggerEnter () { text.SetActive (true); if (Input.GetKeyDown(KeyCode.J)) { anim.Play ("Door_Move"); Sound.SetActive (true); Destroy (rope); Destroy (text); } but the anim not run just if i Change void OnTriggerEnter ---> void Updata will run anim )': i want the animation run if i click in button onTrigger how? and thanks you
@berkaybakacak6 жыл бұрын
Thnaks dude. You are great :)
@CubicBrain
6 жыл бұрын
Thanks, glad you liked it.
@juankacoolx04 жыл бұрын
You are the best one
@blzy23056 жыл бұрын
How to make this with Left Pressed?
@Lord_Piccolo5 жыл бұрын
Thanks, dude. It is useful.
@ChuckyMaster5 жыл бұрын
thank you bro really help ful
@vlad-cristiansecatureanu68205 жыл бұрын
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
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
@seddaouiyassine78145 жыл бұрын
How if we only want it to play 1 time?
@ashoan89657 жыл бұрын
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.
@jasielt.20063 жыл бұрын
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
3 жыл бұрын
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.
@lucutes29364 жыл бұрын
how do I make them movable with WASD
@jimmsdesign-freelancegraph15495 жыл бұрын
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
5 жыл бұрын
attach animator
@MrJacky5 жыл бұрын
Omg thank you so much !!!
@emilyallen7912 Жыл бұрын
It won’t let me add a new state when I right click it just says add behavior
@user-bw6br9ym8z4 жыл бұрын
Thank you bro, but if want in ontriggerenter if press keycode E ----> then the animator will play how?
@omengaming20193 жыл бұрын
nice work
@rickfuzzy5 жыл бұрын
Excellent. Feel like i just leveled up
@CubicBrain
5 жыл бұрын
Awesome! happy that it helped you!
@saipranavkishan70035 жыл бұрын
One question, does that button initiate all animations on character or only one?
@CubicBrain
5 жыл бұрын
The script only works on the animations for the specific gameobject. the name of the animation you put into the anim.Play("") is the animation that will playback.
@thecomedyduo40013 жыл бұрын
how to I make the animation keep repeating until i let go of the key?(for walking)
@CubicBrain
3 жыл бұрын
you might be able to use Input.GetKeyUp to stop the animation
@leongrigoruk6 жыл бұрын
One of the best
@CubicBrain
6 жыл бұрын
Thanks. appreciate it.
@v3vlog5 жыл бұрын
hey I am not seeing empyt in animation controller
@2ndpersonshooter7136 жыл бұрын
Thanks, is useful!
@icantth1nkofanam404 жыл бұрын
mine only works once then it doesnt trigger after that
@tonycaterev41005 жыл бұрын
Great Tutorial, thanks!! I've tried to set this script up for a chest, that trigger an animation in the player_controller. But as soon as i try to interact with the chest, the exception: "MissingComponentException: There is no 'Animator' attached to the "Chest" game object, but a script is trying to access it." --- but i dont need the animator of the chest, i need to trigger the animator of my player controller FROM the chest. Did i need to change something in the "anim = GetComponent();" line? public class Lockpicking : MonoBehaviour { public Animator anim; public GameObject lockpick_ui; public Transform ui_spawn_position; public GameObject ui_spawn; public Random rnd = new Random(); public AudioClip lock_success; public AudioClip lock_failure; public AudioClip lock_fatal_failure; //Amount of successful clicks until opening public int lock_level; // Start is called before the first frame update void Start() { anim = GetComponent(); while (lock_level
@neillien7989
5 жыл бұрын
Try attaching it to another game object, also don't forget the collider.
@grosbarbu57785 жыл бұрын
It's possible to do the same thing with the E key ? If yes how to do that ?
@CubicBrain
5 жыл бұрын
Hi Privelol, You should be able to just change the 1 inside the two double quotes to the desired letter.
@DAvitArm4 жыл бұрын
Thanks man you save me :)
@ruler15594 жыл бұрын
say if I want to get back to the other animation, how do I do it?
@CubicBrain
4 жыл бұрын
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.
@BojanVasilev6 жыл бұрын
hello great tutorial but how can i make when i press again to animation stop and if i press again animation start again
@CubicBrain
6 жыл бұрын
Hi Bojan, You will have to set up an if statement, that looks for the animation state (which animation is currently playing.)
@toddlertech80917 жыл бұрын
great tutorial... Thanks
@CubicBrain
7 жыл бұрын
Thanks man!
@anandpattar31064 жыл бұрын
How to stop the animation?
@Gremlinsmom3 жыл бұрын
This was super helpful! But does anyone know how I can make it stop?
@purel24496 жыл бұрын
anim.GetComponent().SetTrigger("Round"); //why not ?
Пікірлер: 314
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
5 жыл бұрын
What is the second if? the New cube Animation?
@praveenvinopv9929
5 жыл бұрын
@@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
5 жыл бұрын
how do you make it stop when you let go?
@iamthewankerpants
5 жыл бұрын
@@apersonthatsucksatnames1133 Asking the real questions here
@dz_apollo
5 жыл бұрын
@@iamthewankerpants if (Input.GetKeyUp("1"))
literally an hour of forum reading didn't produce the quality of information this 6 minute video gave.
@CubicBrain
6 жыл бұрын
Thank you very much Jake. I really appreciate it.
@bevel1702
6 жыл бұрын
Same!
@AGeekNamedRoss
6 жыл бұрын
Guessing... Udacity forum?
@MrCornerMan
6 жыл бұрын
ikr i was searching forever before i found this
@IvyTeaRN
5 жыл бұрын
literally the same thing
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
4 жыл бұрын
THANK YOU SO MUCH IVE BEEN TRYING TO WORK OUT HOW TO DO THIS FOR AGES :)
@JohnJohnson-ox3bu
3 жыл бұрын
Thanks dude
thank you for being so clear and to the point, really needed that.
@CubicBrain
7 жыл бұрын
Thanks a lot!
Incredible.. Fast and to the point, great tutorial !
@CubicBrain
7 жыл бұрын
Thanks a lot!
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
I like videos like this, no longer than 10 minutes and direct to the point :)
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
6 жыл бұрын
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.
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
6 жыл бұрын
Hi Rodane, thanks for your feedback, I'm glad you liked it.
Great! I had been looking for a really direct and simple example and here it is! Thank you :)
Thank you! after 4 years I could not find a better guide!
This is exactly what I needed thank you!
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!
After several minutes of searching, this was exactly what I needed, thank you!
@oofusmcdoofus
4 жыл бұрын
Me too
@rukasugaberu4792
4 жыл бұрын
Several hours you mean.
thank you sir!! You have saved my life. This was like attemp 50 of trying to get my door to open.
used for my gun game. Thanks very quick and straight to the point.
great video! straight to the point, literally that easy. thanks for your help :)
You are the best! I was looking for the solution for 4 hours! Thank you so much!
@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
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.
Excellent tutorial, thank you so so so so much!!
Awesome Tutorial, it helped me so much. Thank you!
@RUDERUDYTUTORIALS
9 ай бұрын
It's really helpful right.
Works like a charms Nice and simple
Thanks dude It fixed my problems.
Still helpful in 2023 thank you very much for your support.
Cheers, worked first time!
this is a very outdated tutorial, but still works for me, thanks to your easy,simple, to the point explanation. ThankYou!
how about if we want our player collider with trigger box and play animation not press key button how we must change code
thank you very much! It's nice and easy to understand
Very simple and effective, thanks!
@CubicBrain
6 жыл бұрын
Thanks man!
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?
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
5 жыл бұрын
Thanks a lot. will do.
You have saved my unity carrier!!!!!
Finaly i found this Tutorial. Thanks
@CubicBrain Thanks you really showed me how it's done.
Awesome tutorial have had trouble with this for like a year or so :D
@kapex6405
2 жыл бұрын
Also this was super easy to customize
Man this vid helped me get into a club (coding C# and unity) . Thnx
Thanks a lot man, you helped me so much!
how can i stop an animation on releasing button and go back to idle animation in void update?
soo i can direct animation like that using while for example walk while pressing w ?
Thank you man very good tutorial
@CubicBrain
6 жыл бұрын
Thank you very much.
What if I just want it to rotate one time and it should disable any more movement?
Thanks, now I can play the orange justice animation
How can i trigger an animation when pressing a hud button?
Thanks a lot sir u have best solution
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?
What about having more than one animation state? I can't find any information about this issue(
thank you so much about this training
What if there were Different animations to be played on different objects then how will we be able to do that?
How do you make it so that when you release the key it stops the animation
Thank you, very helpful
Helped alot! Thanks!
hey ! i m not able to do the second part of the video...like when i click one the cube isnt rotating Can anyone please help me regarding that i copied the exact same code
can i make that after i pressed 1 animation starts and auto stops?
+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.
Thanks for the video :)
How can i let it play one time and it will automaticly go back to emphty state?
I have a Q why I can't scale my terrine when I use unity ?
I wanted to know how to use Trigger parameters but I figure it out anyway. Thanks.
succinct and precise, awesome!
@CubicBrain
5 жыл бұрын
thanks!
how I rotate my object in the menu page in unity
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
5 жыл бұрын
Thank a lot, and good tip!
Assets/animController.cs(19,19): error CS1502: The best overloaded method match for `UnityEngine.Input.GetMouseButtonDown(int)' has some invalid arguments
hey man i have one small issue the code error says aplay has no definiton
how would I get I to stop when I release the button
GREAT TUTORIAL!
what if i want to be able to stop and start t again?
Thanks Bro, but i have problem i use void OnTriggerEnter () { text.SetActive (true); if (Input.GetKeyDown(KeyCode.J)) { anim.Play ("Door_Move"); Sound.SetActive (true); Destroy (rope); Destroy (text); } but the anim not run just if i Change void OnTriggerEnter ---> void Updata will run anim )': i want the animation run if i click in button onTrigger how? and thanks you
Thnaks dude. You are great :)
@CubicBrain
6 жыл бұрын
Thanks, glad you liked it.
You are the best one
How to make this with Left Pressed?
Thanks, dude. It is useful.
thank you bro really help ful
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
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
How if we only want it to play 1 time?
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.
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
3 жыл бұрын
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.
how do I make them movable with WASD
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
5 жыл бұрын
attach animator
Omg thank you so much !!!
It won’t let me add a new state when I right click it just says add behavior
Thank you bro, but if want in ontriggerenter if press keycode E ----> then the animator will play how?
nice work
Excellent. Feel like i just leveled up
@CubicBrain
5 жыл бұрын
Awesome! happy that it helped you!
One question, does that button initiate all animations on character or only one?
@CubicBrain
5 жыл бұрын
The script only works on the animations for the specific gameobject. the name of the animation you put into the anim.Play("") is the animation that will playback.
how to I make the animation keep repeating until i let go of the key?(for walking)
@CubicBrain
3 жыл бұрын
you might be able to use Input.GetKeyUp to stop the animation
One of the best
@CubicBrain
6 жыл бұрын
Thanks. appreciate it.
hey I am not seeing empyt in animation controller
Thanks, is useful!
mine only works once then it doesnt trigger after that
Great Tutorial, thanks!! I've tried to set this script up for a chest, that trigger an animation in the player_controller. But as soon as i try to interact with the chest, the exception: "MissingComponentException: There is no 'Animator' attached to the "Chest" game object, but a script is trying to access it." --- but i dont need the animator of the chest, i need to trigger the animator of my player controller FROM the chest. Did i need to change something in the "anim = GetComponent();" line? public class Lockpicking : MonoBehaviour { public Animator anim; public GameObject lockpick_ui; public Transform ui_spawn_position; public GameObject ui_spawn; public Random rnd = new Random(); public AudioClip lock_success; public AudioClip lock_failure; public AudioClip lock_fatal_failure; //Amount of successful clicks until opening public int lock_level; // Start is called before the first frame update void Start() { anim = GetComponent(); while (lock_level
@neillien7989
5 жыл бұрын
Try attaching it to another game object, also don't forget the collider.
It's possible to do the same thing with the E key ? If yes how to do that ?
@CubicBrain
5 жыл бұрын
Hi Privelol, You should be able to just change the 1 inside the two double quotes to the desired letter.
Thanks man you save me :)
say if I want to get back to the other animation, how do I do it?
@CubicBrain
4 жыл бұрын
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.
hello great tutorial but how can i make when i press again to animation stop and if i press again animation start again
@CubicBrain
6 жыл бұрын
Hi Bojan, You will have to set up an if statement, that looks for the animation state (which animation is currently playing.)
great tutorial... Thanks
@CubicBrain
7 жыл бұрын
Thanks man!
How to stop the animation?
This was super helpful! But does anyone know how I can make it stop?
anim.GetComponent().SetTrigger("Round"); //why not ?
Thank you!
you are AWESOME!
@CubicBrain
6 жыл бұрын
Thank a lot.