Playing Animation on Trigger in Unity

  Рет қаралды 158,278

SpeedTutor

SpeedTutor

5 жыл бұрын

In this Unity Tutorial, I show you how to animate an object, setup the animation controller, write the C# script and be able to play an animation on a trigger event, as well as stopping it when you exit. Suitable for Unity 5 / 2017 / 2018 and above!
➡️Playing Animation on Trigger (With one line of code): • Play ANIMATIONS - ONE ...
🎁 Get OVER 160+ Scripts, Projects and premium content on my PATREON HERE:
➡️bit.ly/SpeedTutorPatreon
·························································································
🔥 INSANE UNITY SAVINGS: bit.ly/UnitySalesHub
🕹️Synty Publisher Mega Sale: bit.ly/SyntyPublisherMegaSale
🕹️SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks
🕹️Unity New Release Discount Sale: prf.hn/l/BdvEmg3
🕹️Unity WELCOME2022 Offer: bit.ly/UnityWelcome2022OFFER
🔥 INSANE HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
🕹️Humble Tutorial Bundle: bit.ly/MammothUnityTutorialsB...
🕹️Unity ART Bundle: bit.ly/UnityHumbleArtBundle
🕹️Unity TOOLS Bundle: bit.ly/UnityInsaneToolsBundle
🕹️SFX for Games Bundle: bit.ly/SFX-Music-For-Games
🕹️Learn Programming Games Bundle: bit.ly/LearnProgrammingGames
🔥Unity Materials / Files & More:
🕹️CGAxis 400 PBR Material Bundle: bit.ly/CGAxisPBRDeals
🕹️Synty Assets: bit.ly/SyntyLowPolyAssets
🕹️Filebase Assets: filebase.gamedevhq.com/ (Code: SPEEDTUTOR2022 - Sign up for a FREE MONTH)
🔥 UNITY SUBSCRIPTIONS:
🕹️Unity Plus: bit.ly/UnityPlusDeals
🕹️Unity Pro: bit.ly/UnityProDeals
·························································································
💰BIG DISCOUNTS on my website, for my UNITY ASSETS:
➡️www.speed-tutor.com
💬Join the Community Discord:
➡️ / discord
💝 Make a donation to the channel:
➡️www.paypal.me/speedtutor
·························································································
⬇️ SpeedTutor Puzzle Assets:
➡️Unity Store: bit.ly/STUnityStorePuzzlePacks
➡️My Website Discounts: www.speed-tutor.com/
⬇️ SpeedTutor Best Selling Assets:
🧩Adventure Puzzle Kit: bit.ly/STAdventurePuzzleKit
🗒️ Note & Letter System: bit.ly/STNoteLetterSystem
🔍Examine System: bit.ly/STExamineSystem
🔢Keypad System: bit.ly/STKeypadSystem
⬇️SpeedTutor Model Packs:
➡️Unity Store: bit.ly/STUnityStoreModelPacks
➡️My Website Discounts: www.speed-tutor.com/
My Assets include: Gas Mask, Flashlight, Generator, Themed Key , Padlock, Phone, Chess Puzzle, Lever, Valve Puzzle, Fuse Box & Safe Systems. Cardboard, Debris, Massive Models and more!
························································································
⭐ Connect with me:
💬| Discord: / discord
🐦| Twitter: / speedtutor
📱 | Facebook: / speedtutoruk
🖥 | Website: www.speed-tutor.com
·······················································································
#SpeedTutor #Unity #Animation

Пікірлер: 303
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Don't trigger me or I'll throw animation at you! ;) 🔥UNITY SAVINGS: bit.ly/UnitySalesHub 🔥SpeedTutor Unity Store: bit.ly/STUnityStorePuzzlePacks 🔥HUMBLE SAVINGS: bit.ly/HumbleBundleDeals
@turnersaint7956
@turnersaint7956 3 жыл бұрын
a trick : watch series at Flixzone. Been using them for watching a lot of movies these days.
@waynebodhi9617
@waynebodhi9617 3 жыл бұрын
@Turner Saint Definitely, been using Flixzone for years myself :D
@thaddeusazariah5568
@thaddeusazariah5568 3 жыл бұрын
@Turner Saint yup, have been watching on Flixzone for years myself =)
@leoisforevercool
@leoisforevercool 2 жыл бұрын
Tip: If you want your transitions to happen without a delay, uncheck "Has Exit Time" while you have your transition selected in the animator.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
That's a heroic tip, thanks for sharing my friend! :D
@namdol_
@namdol_ 3 жыл бұрын
You are a godsend man. I'm up here for at 1am trying to figure this out for hours for a class demonstration the next morning and I can't thank you enough. Finally works!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I do have another animation tutorial which can make this happen in a line of code which might also help you! :)
@namdol_
@namdol_ 3 жыл бұрын
@@SpeedTutor Awesome! Will give it a watch.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Playing Animation on Trigger (With one line of code): kzfaq.info/get/bejne/oddyespnt9PJYWQ.html&
@SpaceDodo
@SpaceDodo 5 жыл бұрын
Do everything as he says exactly and you won't hate yourself
@elisabethmarx7940
@elisabethmarx7940 3 жыл бұрын
This also works in 2D! I tried this tutorial and at first I struggled a lot because nothing happened and I didn't know what I had done wrong. Then I realized if you are using 2D Colliders etc. you need to change one line of code to make it work: private void OnTriggerEnter2D(Collider2D other)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're exactly right! :) I do also have a couple of recent tutorials where I show you how to do this in an even easier way! :)
@cjandlottie
@cjandlottie 5 жыл бұрын
God you need way more views. This is simple and very dynamic within a game. Thanks!!
@SpeedTutor
@SpeedTutor 5 жыл бұрын
No problem at all! :)
@anthonycollins7992
@anthonycollins7992 5 жыл бұрын
Thank you so much for this, this is the first tut that i've found that works with my set up.
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Great to hear it, thanks for watching! :)
@notjohn321
@notjohn321 4 жыл бұрын
Thank you so much!! i found this tutorial after two days of trying to make a working elevator and it made it work!!
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Glad I could help!
@StigDesign
@StigDesign 5 жыл бұрын
Awsome to see you back with tutorial :D so this is the mecanic to activate animation state/StateMachine :)
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Thanks man! Good to hear from you again! :)
@StigDesign
@StigDesign 5 жыл бұрын
@@SpeedTutor thank you:D
@kaleemfarooq2190
@kaleemfarooq2190 3 жыл бұрын
OMG Thanks! I have been trying to figure this out for so long!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Glad I could help! :)
@bluemodize7718
@bluemodize7718 2 жыл бұрын
Thanks after 1 day of research finally found a good toutorial
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm glad you found this, thanks for watching! :D
@paulrobinson5490
@paulrobinson5490 5 жыл бұрын
Nice, could find several uses for this little gem :)
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Great to hear it, thanks for watching! :)
@ankush1880
@ankush1880 4 жыл бұрын
Thank you, God bless you.
@dreamescence
@dreamescence 5 жыл бұрын
very good tutorial hope your channel gets big like brackeys keep making tutorials like this
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Thanks very much! :)
@anshulgoyal1095
@anshulgoyal1095 4 жыл бұрын
Thank you for this tutorial man!
@SpeedTutor
@SpeedTutor 4 жыл бұрын
No worries at all! :)
@BonBon-qt4xb
@BonBon-qt4xb 4 жыл бұрын
You're a life saver man, thanks a lot
@SpeedTutor
@SpeedTutor 4 жыл бұрын
No problem at all, glad I could help! :)
@ragnaesports5519
@ragnaesports5519 4 жыл бұрын
Thank you for this tutorial!
@SpeedTutor
@SpeedTutor 4 жыл бұрын
You are very welcome!
@inamurphy7447
@inamurphy7447 4 жыл бұрын
great tutorial! thank you very much
@SpeedTutor
@SpeedTutor 4 жыл бұрын
No problem at all, thanks for watching! :)
@diaryofarobot
@diaryofarobot Жыл бұрын
Thank you very much, it is really useful. I was thinking of making an animation on my channel and it may help me.😬
@SpeedTutor
@SpeedTutor Жыл бұрын
Great to hear it, my friend. Good luck! :D
@mellow_fellow
@mellow_fellow 4 жыл бұрын
Thanks man , I love you
@SpeedTutor
@SpeedTutor 4 жыл бұрын
No worries, thanks for watching! :)
@UwuSwaggins
@UwuSwaggins 2 жыл бұрын
Increadibly healpful. Thank you!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
That's no worries! Thanks for coming along to watch my friend! :)
@AKSenor24
@AKSenor24 5 жыл бұрын
Good job! Thanks ...
@soulstriker6
@soulstriker6 Жыл бұрын
wow thx! you teached me how to use unity animations fully!
@SpeedTutor
@SpeedTutor Жыл бұрын
Glad to hear that!
@wadec3572
@wadec3572 4 жыл бұрын
OHHHH god thanks you mann !! love you !
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm glad it helped you out! :)
@adriantoth1230
@adriantoth1230 3 жыл бұрын
Man! You are a legend! Thank you very much!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're very welcome!
@Goggalor1990
@Goggalor1990 3 жыл бұрын
Works great, thank you!
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're welcome!
@therealHorto
@therealHorto 5 жыл бұрын
I would love seeing a animation tutorial ive tried to get into it but every time i do i struggle with learning how to animate stuff.
@SpeedTutor
@SpeedTutor 5 жыл бұрын
What sort of things do you struggle to animate?
@ifredpingplay468
@ifredpingplay468 2 жыл бұрын
Thanks Worth it bro :) thanks for explaining this simple
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm really glad you think so, thanks for coming along to check this out! :D
@Pmz98
@Pmz98 3 жыл бұрын
Omg, thank you so much.
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No problem at all! :)
@ahmadelashi3944
@ahmadelashi3944 5 ай бұрын
Thanks so much. I was about to quit. New sub!!
@SpeedTutor
@SpeedTutor 5 ай бұрын
Haha! You're very welcome, I'm glad you didn't quit. What are you creating?
@acikgozemre
@acikgozemre 3 жыл бұрын
Thank you so much! I was using to stop trigger with else but now realized I d had to exit :)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
Glad I could help! I do have another tutorial on playing animations on trigger, which is easier and more recent! :)
@acikgozemre
@acikgozemre 3 жыл бұрын
@@SpeedTutor Thank you i will watch it
@AdAstra91
@AdAstra91 2 жыл бұрын
Many thanks m8 u helped me A LOT !!!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I'm glad you think so! I also have an updated tutorial which may help you out too! :) It's in the description.
@keremsivasloglu9548
@keremsivasloglu9548 Жыл бұрын
thank you so much this was really helpfull
@SpeedTutor
@SpeedTutor Жыл бұрын
You're very welcome, I even have an even easier tutorial on playing animations in the description! :)
@greeng448
@greeng448 2 жыл бұрын
It work very well on my zombie animation thank you
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Great to hear it! :D
@snehasinghgaur9909
@snehasinghgaur9909 Жыл бұрын
Thank you so much dude ❤
@SpeedTutor
@SpeedTutor Жыл бұрын
You're welcome!
@4veinte584
@4veinte584 5 жыл бұрын
Gracias hermano saludos desde México
@EzXet
@EzXet 2 жыл бұрын
thank you so much bro
@SpeedTutor
@SpeedTutor 2 жыл бұрын
No problem at all! :D
@zulaiman2151
@zulaiman2151 2 жыл бұрын
Thanks bro, Really appreciate it.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
That's no problem at all! :)
@zaidtaweel2542
@zaidtaweel2542 4 жыл бұрын
underrated channel
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Thanks man! :)
@leoisforevercool
@leoisforevercool 2 жыл бұрын
Thank you, you hero and saint of a man
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I am glad to be of service to you my friend! :D
@i_amirb
@i_amirb 8 ай бұрын
Awesome ❤❤
@SpeedTutor
@SpeedTutor 8 ай бұрын
Thanks for watching, how did you find me?
@ahmedsleem81
@ahmedsleem81 5 жыл бұрын
Very Useful tutorial, short simple and yet very very useful
@aryanjumani4524
@aryanjumani4524 4 жыл бұрын
Great tutorial and saved me lots of time researching about animation controllers but I ran through an error for my game. It finishes the animation and only then starts the new animation when my parameter is set to true. Can you cut the animation immediately and start the new one as soon as the bool is set to true? Please help.
@ZenaGreen
@ZenaGreen 4 жыл бұрын
PERFECT
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Great to hear it, thanks for watching! :)
@xueniyu8187
@xueniyu8187 4 жыл бұрын
Hi! I just found your channel and I'm impressed! I have a question if you don't mind, that is, does this work if I only want my animation to trigger once? ( for etc. Book falling from bookshelves by itself) Thanks and keep making good content! :)
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Yes of course! :)
@xueniyu8187
@xueniyu8187 4 жыл бұрын
@@SpeedTutor That's great to know, I'll try it out then! Thanks for the reply too! I am a beginner so your channel is a really big help! One of the best out there ~ (I mean it)
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Thanks very much! :) I really appreciate it!
@alielsayed8078
@alielsayed8078 4 жыл бұрын
i cant thank you enough
@SpeedTutor
@SpeedTutor 4 жыл бұрын
I'm glad to hear it! :)
@gmangman123
@gmangman123 Жыл бұрын
good tutorial again my friend!
@SpeedTutor
@SpeedTutor Жыл бұрын
Thanks man, I even have another tutorial which helps you do this in an even easier way. It's in the description of this video :)
@gmangman123
@gmangman123 Жыл бұрын
@@SpeedTutor take look my demo! kzfaq.info/get/bejne/a7hdl7eAzd2lnmg.html
@inboraStudio
@inboraStudio 2 жыл бұрын
thank you so much bro love you from india
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You're very welcome, my friend! :)
@publicstaticvoid3224
@publicstaticvoid3224 5 жыл бұрын
Good job. You can also turn off the mesh renderer to give the player the illusion of it being automatic.
@nickw6969
@nickw6969 Жыл бұрын
Hi! Great tutorial, I have been using it a lot in my game. How do you make the animation only play once when you enter the trigger?
@SpeedTutor
@SpeedTutor Жыл бұрын
You can also check out my newer tutorials on this, which may help you out even easier! :)
@TajuSingh
@TajuSingh 3 жыл бұрын
Great
@marcusbean6658
@marcusbean6658 4 жыл бұрын
I even duplicated this script as "PlayMyAnimation2" and input my 2nd animation but it does nothing, is it trying to call from the same animator controller?
@Nick-rq4gy
@Nick-rq4gy 3 жыл бұрын
excellent video thank you, I needed this badly😁😁😁🚀🚀🚀👍👍👍👍🌈🌈🌈🌈
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You’re welcome 😊
@charlesferry9465
@charlesferry9465 4 жыл бұрын
Nice tutorial bro but i still don't know how to make obj fell when player enter trigger please reply
@ThirdMoveStudios
@ThirdMoveStudios 5 жыл бұрын
Hi! My iOS app is locking the phone’s screen after 1 minute without clicking on the screen. I started with Unity recently and I’m not a programmer at all. Do you know what I need to do? Thanks!
@0aleolijest678
@0aleolijest678 3 жыл бұрын
Thanks
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're very welcome! :)
@davidmiller6452
@davidmiller6452 3 жыл бұрын
Great tutorial, well done. If I am using an arcamera to trigger would I need to change "player" to "arcamera" in the script?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No, no - You can keep it as player! :)
@davidmiller6452
@davidmiller6452 3 жыл бұрын
@@SpeedTutor even though my ar camera is labeled "Maincamera"
@davidmiller6452
@davidmiller6452 3 жыл бұрын
I would be triggering with the ar camera
@davidmiller6452
@davidmiller6452 3 жыл бұрын
@@SpeedTutor do you have a tutorial for adding sound as an event in the annimation?
@RaceSmokie
@RaceSmokie 5 жыл бұрын
Again one great tutorial from you [great tutorial = understandable+quick+straight to the point]. Thank you. But I am wondering is it possible to make something like universal script to start anim? What I actually mean is, {bare in mind im totally noob in scripting} instead of -private- thing can we have it -public-? So to use one script for different objects and different animations? Just, you know, there is that Door what have to be open, so I will just drop that script on the door and than drop already made animation from previous door and maybe this door will open not by "player" but by some "rigid body tagged: ball" which I will just drop from the scene in to the specific field in the script in Unity properties panel. I hope you you see what I mean :)
@SpeedTutor
@SpeedTutor 5 жыл бұрын
I know exactly what you mean, you could just prefab your door which has the script on it and duplicate that same thing. So it's almost like two copies of the same thing but they would work independantly! :)
@theknard3202
@theknard3202 3 жыл бұрын
thanks
@SpeedTutor
@SpeedTutor 3 жыл бұрын
You're very welcome! :)
@BitterTast3
@BitterTast3 2 жыл бұрын
I love you.
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Ditto! Thanks for watching my friend! :D
@mrunmaymycode748
@mrunmaymycode748 2 жыл бұрын
Thank You So Much...
@SpeedTutor
@SpeedTutor 2 жыл бұрын
No problem at all, I do also have an even easier tutorial which you can checkout too! :D
@mrunmaymycode748
@mrunmaymycode748 2 жыл бұрын
@@SpeedTutor Sure I will... Telling the truth, I have been looking for this function from months until I got your video on YT...😁😁😁🤩🤩🤩
@SpeedTutor
@SpeedTutor 2 жыл бұрын
Awesome! Glad I could help you out. Good luck with your projects! :D
@mrunmaymycode748
@mrunmaymycode748 2 жыл бұрын
@@SpeedTutor TYSM...‼😁
@ahsanshah7373
@ahsanshah7373 2 жыл бұрын
Works great!!!! I set up 3 colliders with different names to play different animations but when my player collides with the first one it plays all my animations one after the other.I wanted it to play different animations on different colliders positions.:(
@SpeedTutor
@SpeedTutor 2 жыл бұрын
That shouldn't happen, but I do have a tutorial which is updated from this. It's in the description which might help you! :)
@schindoneer198
@schindoneer198 3 жыл бұрын
@SpeedTutor How can i do this on click?
@pppparanoidddd
@pppparanoidddd 5 жыл бұрын
Could you do a door tutorial?
@SpeedTutor
@SpeedTutor 5 жыл бұрын
I'll see what I can do! :)
@mustachebutter
@mustachebutter 4 жыл бұрын
Thank you, works like a charm! Although I have a question, is it normal for it to have a delay before playing the animation? I noticed it took like about .5 seconds when you step in the trigger box. I tried for an animation for my door and it also has a delay too. Is there anyway to control it or Unity is doing something in the background?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
I do also have another tutorial on playing animation which might also be helpful for you! kzfaq.info/get/bejne/ocyIh91yxp-rZJs.html
@mustachebutter
@mustachebutter 4 жыл бұрын
@@SpeedTutor thanks a lot, this is perferct.
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Great to hear it! :)
@rocketpadmedia4918
@rocketpadmedia4918 4 жыл бұрын
You could also try changing the 'speed' on your DefaultState to something like 10 so it cycles through faster and reduces the delay getting to the next animation event.
@vladislavershov8832
@vladislavershov8832 4 жыл бұрын
thanks 1000 + 1 example how set bool = true
@cubingle6843
@cubingle6843 4 жыл бұрын
how would i get the animation to lock in place when it finishes its animation? I'm trying to make a sliding door.
@csrikanth0007
@csrikanth0007 3 жыл бұрын
set the desired final state of obj in another state and keep it as the last one in your animator
@KeiNovak
@KeiNovak 5 жыл бұрын
There seems to be a slight delay after you enter the collider and before the animation starts. What's the reason for that? Or am I just not seeing it correctly?
@Goggalor1990
@Goggalor1990 3 жыл бұрын
I don't know if you ever figured it out, but if you did please let me know lol. It does have a slight delay, not sure of the reasoning.
@KeiNovak
@KeiNovak 3 жыл бұрын
@@Goggalor1990 Sorry, It's been so long so I don't remember. Looking at the video again though, it seems like it may be the animator controller. IIRC, it does some auto-blend thing for blending between animations... in this case it may just be blending from a Stop "animation" to the actual Spinning animation... hence the weird spin-up time and spin-down. Let me know if that helps.
@shivc03
@shivc03 Жыл бұрын
For example what if I want to trigger 10 vens on one trigger. How do I do that?
@monsterboyx7076
@monsterboyx7076 3 жыл бұрын
i want to implement it on a moving a character
@DaveSucker
@DaveSucker Жыл бұрын
plz man tell me bro haw can i just make a ui button witch rotate my car backward and forward
@handkey9451
@handkey9451 5 жыл бұрын
I hope next time you write the script, maybe you can zoom or enlarge it a bit so maybe some of us will see the script more clearly, thank you
@SpeedTutor
@SpeedTutor 5 жыл бұрын
I'll keep this in mind, thanks! :)
@elbladel
@elbladel 4 жыл бұрын
It is working, thanks! But what if I don't want the animation to be a loop?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
You can select the animation itself and untick "LoopTime" I think!
@elbladel
@elbladel 4 жыл бұрын
@@SpeedTutor It worked! Thank you so much!!!
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Haha, no worries at all! :)
@yeevon3852
@yeevon3852 4 жыл бұрын
Hi, I am doing that player trigger the bomb, then explosion animation occur, the concept is same with this ?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Absolutely! :)
@Goblexter
@Goblexter 5 жыл бұрын
You might want to increase the font size for your videos. Can't see shit unless watching in fullscreen.
@ROUGETHEBAT456
@ROUGETHEBAT456 Жыл бұрын
I can't get the animation to quit when I leave the box that has the trigger
@GoroPvMRunescape
@GoroPvMRunescape 4 жыл бұрын
Hey great video! I based my animation off this video but Instead of the player being the trigger on an object, the object is a trigger on the player. When the object hits the player it is destroyed and the bool stays true, i tried using an else statement to keep it false otherwise, but it seems the object being destroyed on the player is keeping the bool to true. Any ideas on how to fix that?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
When you destroy the trigger, make sure you to turn the bool to false!
@018FLP
@018FLP 3 жыл бұрын
This is awesome! And what if i want the animation to be played in the Player instead? =]
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not sure what you mean?
@018FLP
@018FLP 3 жыл бұрын
@@SpeedTutor For example: in a 3d platformer, there's a plataform where the goal of the game is. And when the player step on it, the character makes a winning animation, like "\o/" . How can i make the animation play from this outside factor within the player on this example?
@babaganoosh1969
@babaganoosh1969 5 жыл бұрын
This would be good for traps..quick question..instead of a player walking into the trigger can a object be used? ( a rock on a floor tile for example )
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Yes, in exactly the same way. As long as one of the objects has a rigidbody, you could do it in exactly the same way! :)
@milan7689
@milan7689 4 жыл бұрын
does this also work with just a collider or do you need to have a cube showing
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Just with a collider!
@breaola2470
@breaola2470 4 жыл бұрын
Hi, thanks for the tutorial. I have a problem with the MyAnimationController variable, though. I am using an array of prefabs as collision triggers, if I set the component that MyAnimationController asks through the inspector (as seen at 8:20) on those prefabs (I am assigning it "Avatar", as my Avatar is my player and it's the GameObject on which I want to change the animation on trigger collider with the prefabs), even if I hit "apply all" in the inspector, after I delete the prefabs from the hierarchy (as I only leave their spawner) and I start the game I get this error: " UnassignedReferenceException: The variable MyAnimationController of playMyAnimation has not been assigned. You probably need to assign the MyAnimationController variable of the playMyAnimation script in the inspector. UnityEngine.Animator.SetBool (System.String name, System.Boolean value) (at /Users/builduser/buildslave/unity/build/Runtime/Animation/ScriptBindings/Animator.bindings.cs:343) playMyAnimation.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/playMyAnimation.cs:13)" And if I reimport the prefabs on the hierarchy from the assets, the component "Avatar" which I assigned to MyAnimationController disappears. Any idea about how to solve this?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
The connections are sometimes lost when you use prefabs, you could always search for the controller manually when you want inside those scripts. I'm not sure if that's helpful or not?
@breaola2470
@breaola2470 4 жыл бұрын
@@SpeedTutor I hope it is, I'm still not confident in C# and unity to try what you suggest, but today I'll try to work with scriptable objects instead of prefabs to see if something changes. Thanks buddy!
@Snikabarz
@Snikabarz 3 жыл бұрын
Hey, I'm making a game right now that requires a lot of animations that need to be played when entering a trigger, and I mean A LOT when I say a lot. Wouldn't doing this way require me to make a script and animator set up for every single animation I need triggered? If so, is it still possible to do it other ways that will save me the time?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I do have another animation tutorial which you could just call the name of your animation, on the trigger event without this setup! It's on my channel! Just search "Animation".
@Snikabarz
@Snikabarz 3 жыл бұрын
@@SpeedTutor dude that just saved my life, thanks. That should speed up the developing process quite a bit
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm happy to hear it! :) You watched the older one?
@golflefleur2767
@golflefleur2767 3 жыл бұрын
@@Snikabarz which video was it? i really need it!!!
@CraftyMaelyss
@CraftyMaelyss 4 жыл бұрын
I have a question: I want to set up a barrier/trigger, so when the player enters it, it makes them turn around and walk away from it (not allowing them to continue in the same direction) would this work for that?
@SpeedTutor
@SpeedTutor 4 жыл бұрын
That's a good question, it may work but you'd likely want to put your player on a path which they follow to the point you want to send them back too. Lets say for example, taking input controls away from your players and then translating the character position somewhere else!
@CraftyMaelyss
@CraftyMaelyss 4 жыл бұрын
@@SpeedTutor I tried that but ran into a problem, for some reason once the animation is done, it cancels out gravity P: Do you know how to make the animation work so that it doesn't tamper in gravity? (So it works same as normal once the animation is over?)
@SpeedTutor
@SpeedTutor 4 жыл бұрын
I'd probably say that you don't use an animation to take control of your player, just move your player away manually. Are you doing a 3D game? Third person on Third person?
@CraftyMaelyss
@CraftyMaelyss 4 жыл бұрын
@@SpeedTutor Yes, I'm doing a 3D game, however this part of the game is in 1st person but still has a model, so the arms and hair are visible. How would I stop the animation from disabling the gravity on the model though? Is there an option for gravity to always be applied to the model, even during animations? Also thank you so much for the fast response too! This is my first game but still a big project and I'm pretty determined to make it the best I can :)
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Rather than doing this, could you just enabled a new camera which moves instead of your players? Then give control back to the original player?
@marcusbean6658
@marcusbean6658 4 жыл бұрын
Any way to use multiple events through this one script? Using it for elevator doors, got the first floor working, and dont know how to go about adding a second animation with its own new trigger for the second or third floor.
@SpeedTutor
@SpeedTutor 4 жыл бұрын
Why not add two to the same script?
@valeriopavan
@valeriopavan 4 жыл бұрын
Just a curiosity in the script: Why did you use [SerializeField] and private, instead of a public variable? :)
@SpeedTutor
@SpeedTutor 4 жыл бұрын
It makes private variables visible in the inspector. It's good to keep variables private UNLESS they actually need to be public (Across other scripts) :) - I hope that helps!
@baxterclagmoar9333
@baxterclagmoar9333 5 жыл бұрын
Is there some way to make this work with a Raycast? I want to have my player look at an object, press E, and then an animation plays. However, doing the method in this tutorial doesn't seem to work and I don't know why... The raycast works, I have a debug. log telling me that. It's just that the bool is not changing to true for some reason
@RespectTheNerd
@RespectTheNerd 4 жыл бұрын
Have a similar problem with an animation that's supposed to activate on a button press, you don't happen to have solved it yet? Would love to see the solution.
@BLOTROPS
@BLOTROPS 2 жыл бұрын
i tried to do the script in 2d and i got this errore Assets\Playeranimation.cs(13,35): error CS1061: 'Animator' does not contain a definition for 'Setbool' and no accessible extension method 'Setbool' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?)
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I have a different tutorial which will show you how to create an animation and play it in code, easier than this one. I think I've linked it in the video description! :)
@justynkrupa44
@justynkrupa44 11 ай бұрын
good
@SpeedTutor
@SpeedTutor 11 ай бұрын
Thanks!
@TheBlackbirdii
@TheBlackbirdii 5 жыл бұрын
does should work with unity 2017 ? or specific to 2018 ? can you do one with timeline
@SpeedTutor
@SpeedTutor 5 жыл бұрын
It would easily work with Unity 5 / 2017 / 2018 and onwards.
@TheBlackbirdii
@TheBlackbirdii 5 жыл бұрын
@@SpeedTutor off topic any chance to make a tutorial how to add rumble when player get hit or enter a trigger ?
@TheGamingWiccan
@TheGamingWiccan 5 жыл бұрын
How can i get this to play sound along with an animation cus im wanting to make a horror game based on 21 years of reoccurring nightmares which is about up until a year ago im 22 now and turning 23 on the third of October
@SpeedTutor
@SpeedTutor 5 жыл бұрын
Just activate tehesong when the animation starts?
@sennz0r129
@sennz0r129 2 жыл бұрын
I have a problem, for some reason my animator doesnt do the transition when i want it to (player needs to click the left mouse button to initialise) the parameter is completed so the condition becomes true but nothing happens within the animator, i am using the mouse button down version of it, any solutions, would mean a lot and thank you!
@SpeedTutor
@SpeedTutor 2 жыл бұрын
You could take a look at the newer animation video I've created in a the description and/or pinned comment. I should you how to do it in an even easier way. It might help! :)
@saraschroder7523
@saraschroder7523 Жыл бұрын
I did this and it works but the animation doesn't play at the speed I have it set to. Basically I have a player interact with a switch to lower lava on the ground. When the player interacts with the switch the lava instantly disappears, when in the animation it was slowly going down. Is there a way to have it not be instant?
@SpeedTutor
@SpeedTutor Жыл бұрын
I'm not really sure about that one, can you purposely slow the animation down?
@milanreusch4570
@milanreusch4570 8 ай бұрын
I got a problem with [SerializedField] it tells me i have nothing referenced or something like that. My Code is the same except for the Names, it doesn‘t highlight the code line for the Animator… what am i doing wrong?
@SpeedTutor
@SpeedTutor 8 ай бұрын
It needs to be [SerializeField] without the "D" :)
@ragnaesports5519
@ragnaesports5519 3 жыл бұрын
Hi, if animation tag.target get destroyed? animation stuck and play forever, what i should type to make animation stop when tag.target get destroyed?
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I'm not really sure as this isn't something I've looked into before :(
@danielc04
@danielc04 5 жыл бұрын
It worked, but suddenly it stopped working and Idk why
@ScilexGuitar
@ScilexGuitar 3 жыл бұрын
This is great but I was kind of hoping for how the "Trigger" parameter works, instead of the bool
@SpeedTutor
@SpeedTutor 3 жыл бұрын
I do have a tutorial on creating an animation on a trigger with one line of code, it's on my channel if you search "Animation"
@ScilexGuitar
@ScilexGuitar 3 жыл бұрын
@@SpeedTutor Thank you! Will watch the video but I think I got it to work anyways :)
@SpeedTutor
@SpeedTutor 3 жыл бұрын
No worries at all! :)
@technocraftSTUDIO
@technocraftSTUDIO 2 жыл бұрын
I want to trigger a death animation on hitting an obstacle in my endless running game, will you please help
@SpeedTutor
@SpeedTutor 2 жыл бұрын
I have a new tutorial about this, which might help! :) Its in the description.
@nobody_there_
@nobody_there_ 5 ай бұрын
You forgot something... when i clic on conditions, it says "Parameter does not exist in Controller".... so ?
@doodlezk2832
@doodlezk2832 4 жыл бұрын
5:15 when I press the + button it doesn't show any layer types, it just adds a layer. what should I do?
@MoreNimrod
@MoreNimrod 3 жыл бұрын
You need to click on the Parameters tab, not the Layers tab. You're adding a bool as a Parameter and not as a Layer.
Escaping Unity Animator HELL
18:18
Lost Relic Games
Рет қаралды 502 М.
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 9 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 28 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
OPENING a DOOR in UNITY on TRIGGER EVENT
8:20
SpeedTutor
Рет қаралды 110 М.
Unity 3D: Animate & Trigger A Door
21:30
Kyle Broad
Рет қаралды 43 М.
10 Minutes vs. 10 Years of Animation
19:29
Isto Inc.
Рет қаралды 764 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 520 М.
MAIN MENU in Unity (Best Menu Tutorial 2024)
1:24:21
SpeedTutor
Рет қаралды 197 М.
Cutscene in Unity 3D | Timeline in Unity | CG Aura
14:13
CG AURA
Рет қаралды 135 М.
How To Open Doors Easily in Unity With Trigger Events
6:52
Fist Full of Shrimp
Рет қаралды 1,5 М.
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 9 МЛН