Playing Animation on Trigger in Unity

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
    @SpeedTutor3 жыл бұрын

    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
    @leoisforevercool2 жыл бұрын

    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.

  • @SpaceDodo
    @SpaceDodo5 жыл бұрын

    Do everything as he says exactly and you won't hate yourself

  • @cjandlottie
    @cjandlottie5 жыл бұрын

    God you need way more views. This is simple and very dynamic within a game. Thanks!!

  • @SpeedTutor

    @SpeedTutor

    5 жыл бұрын

    No problem at all! :)

  • @elisabethmarx7940
    @elisabethmarx79403 жыл бұрын

    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! :)

  • @SpeedTutor
    @SpeedTutor3 жыл бұрын

    Playing Animation on Trigger (With one line of code): kzread.info/dash/bejne/naV2qclvgtDLYZM.html&

  • @anthonycollins7992
    @anthonycollins79925 жыл бұрын

    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
    @notjohn3214 жыл бұрын

    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!

  • @marcusbean6658
    @marcusbean66584 жыл бұрын

    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?

  • @aryanjumani4524
    @aryanjumani45244 жыл бұрын

    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.

  • @StigDesign
    @StigDesign5 жыл бұрын

    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

  • @ankush1880
    @ankush18804 жыл бұрын

    Thank you, God bless you.

  • @kaleemfarooq2190
    @kaleemfarooq21903 жыл бұрын

    OMG Thanks! I have been trying to figure this out for so long!

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    Glad I could help! :)

  • @ThirdMoveStudios
    @ThirdMoveStudios5 жыл бұрын

    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!

  • @paulrobinson5490
    @paulrobinson54905 жыл бұрын

    Nice, could find several uses for this little gem :)

  • @SpeedTutor

    @SpeedTutor

    5 жыл бұрын

    Great to hear it, thanks for watching! :)

  • @therealHorto
    @therealHorto5 жыл бұрын

    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?

  • @BonBon-qt4xb
    @BonBon-qt4xb4 жыл бұрын

    You're a life saver man, thanks a lot

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    No problem at all, glad I could help! :)

  • @anshulgoyal1095
    @anshulgoyal10954 жыл бұрын

    Thank you for this tutorial man!

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    No worries at all! :)

  • @UwuSwaggins
    @UwuSwaggins2 жыл бұрын

    Increadibly healpful. Thank you!

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    That's no worries! Thanks for coming along to watch my friend! :)

  • @ragnaesports5519
    @ragnaesports55193 жыл бұрын

    Thank you for this tutorial!

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    You are very welcome!

  • @dreamescence
    @dreamescence4 жыл бұрын

    very good tutorial hope your channel gets big like brackeys keep making tutorials like this

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    Thanks very much! :)

  • @charlesferry9465
    @charlesferry94654 жыл бұрын

    Nice tutorial bro but i still don't know how to make obj fell when player enter trigger please reply

  • @inamurphy7447
    @inamurphy74474 жыл бұрын

    great tutorial! thank you very much

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    No problem at all, thanks for watching! :)

  • @shivc03
    @shivc03 Жыл бұрын

    For example what if I want to trigger 10 vens on one trigger. How do I do that?

  • @bluemodize7718
    @bluemodize77182 жыл бұрын

    Thanks after 1 day of research finally found a good toutorial

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    I'm glad you found this, thanks for watching! :D

  • @DaveSucker
    @DaveSucker Жыл бұрын

    plz man tell me bro haw can i just make a ui button witch rotate my car backward and forward

  • @Goggalor1990
    @Goggalor19903 жыл бұрын

    Works great, thank you!

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    You're welcome!

  • @AKSenor24
    @AKSenor245 жыл бұрын

    Good job! Thanks ...

  • @4veinte584
    @4veinte5845 жыл бұрын

    Gracias hermano saludos desde México

  • @adriantoth1230
    @adriantoth12303 жыл бұрын

    Man! You are a legend! Thank you very much!

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    You're very welcome!

  • @schindoneer198
    @schindoneer1983 жыл бұрын

    @SpeedTutor How can i do this on click?

  • @monsterboyx7076
    @monsterboyx70763 жыл бұрын

    i want to implement it on a moving a character

  • @yeevon3852
    @yeevon38524 жыл бұрын

    Hi, I am doing that player trigger the bomb, then explosion animation occur, the concept is same with this ?

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    Absolutely! :)

  • @cubingle6843
    @cubingle68434 жыл бұрын

    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

  • @mellow_fellow
    @mellow_fellow4 жыл бұрын

    Thanks man , I love you

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    No worries, thanks for watching! :)

  • @ifredpingplay468
    @ifredpingplay4682 жыл бұрын

    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

  • @soulstriker6
    @soulstriker6 Жыл бұрын

    wow thx! you teached me how to use unity animations fully!

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    Glad to hear that!

  • @wadec3572
    @wadec35723 жыл бұрын

    OHHHH god thanks you mann !! love you !

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    I'm glad it helped you out! :)

  • @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! :)

  • @GoroPvMRunescape
    @GoroPvMRunescape4 жыл бұрын

    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!

  • @AdAstra91
    @AdAstra912 жыл бұрын

    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.

  • @baxterclagmoar9333
    @baxterclagmoar93335 жыл бұрын

    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.

  • @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! :)

  • @marcusbean6658
    @marcusbean66584 жыл бұрын

    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?

  • @zulaiman2151
    @zulaiman21512 жыл бұрын

    Thanks bro, Really appreciate it.

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    That's no problem at all! :)

  • @milan7689
    @milan76894 жыл бұрын

    does this also work with just a collider or do you need to have a cube showing

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    Just with a collider!

  • @ROUGETHEBAT456
    @ROUGETHEBAT456 Жыл бұрын

    I can't get the animation to quit when I leave the box that has the trigger

  • @ragnaesports5519
    @ragnaesports55193 жыл бұрын

    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 :(

  • @TheGamingWiccan
    @TheGamingWiccan5 жыл бұрын

    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?

  • @Pmz98
    @Pmz983 жыл бұрын

    Omg, thank you so much.

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    No problem at all! :)

  • @snehasinghgaur9909
    @snehasinghgaur9909 Жыл бұрын

    Thank you so much dude ❤

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    You're welcome!

  • @greeng448
    @greeng448 Жыл бұрын

    It work very well on my zombie animation thank you

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    Great to hear it! :D

  • @sennz0r129
    @sennz0r1292 жыл бұрын

    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! :)

  • @doodlezk2832
    @doodlezk28324 жыл бұрын

    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.

  • @BLOTROPS
    @BLOTROPS2 жыл бұрын

    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! :)

  • @babaganoosh1969
    @babaganoosh19695 жыл бұрын

    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! :)

  • @danielc04
    @danielc044 жыл бұрын

    It worked, but suddenly it stopped working and Idk why

  • @CazeElite
    @CazeElite5 жыл бұрын

    I need help, on the editor the animation works fine but on build the animation doesn't work.

  • @SpeedTutor

    @SpeedTutor

    5 жыл бұрын

    That's strange, has anyone reported this issue online?

  • @leoisforevercool
    @leoisforevercool2 жыл бұрын

    Thank you, you hero and saint of a man

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    I am glad to be of service to you my friend! :D

  • @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?

  • @valeriopavan
    @valeriopavan4 жыл бұрын

    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!

  • @xueniyu8187
    @xueniyu81874 жыл бұрын

    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!

  • @acikgozemre
    @acikgozemre3 жыл бұрын

    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

  • @KeiNovak
    @KeiNovak5 жыл бұрын

    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.

  • @EzXet
    @EzXet2 жыл бұрын

    thank you so much bro

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    No problem at all! :D

  • @SpyroDragon
    @SpyroDragon Жыл бұрын

    Did the scripting part change, it doesn't autofill like your video..

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    Does the autofill work for you, nromally?

  • @robertmcdonald5785
    @robertmcdonald5785 Жыл бұрын

    I am unable to drag and drop my animation controller into my script component. Do why this could be?

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    Any errors?

  • @breaola2470
    @breaola24704 жыл бұрын

    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!

  • @noname6573
    @noname65735 жыл бұрын

    What does the Code [SerializeField] do? Why did you use it?

  • @SpeedTutor

    @SpeedTutor

    5 жыл бұрын

    It makes a private variable visible in the inspector, so we don't have to have everything public.

  • @technocraftSTUDIO
    @technocraftSTUDIO2 жыл бұрын

    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.

  • @Nick-rq4gy
    @Nick-rq4gy3 жыл бұрын

    Dear Speed Tutor, In my scene I got my FPS Character Controller (the player) and my Zombie following the FPS Character Controller with script, and I added a attack trigger so when the FPS Character Controller gets close the zombie attacks the FPS Character Controller at 4.0 Stopping Distance. So all I need to do is the health bar goes down when the zombie attacks the FPS Character Controller, does anyone know any tutorials that show the C# Visual Studio code or in Bolt Visual Scripting to make the health bar go down when the zombie attacks the FPS Character Controller? Or can anyone walk me through it on Unity 3D? I cannot find any KZread tutorials on a health bar going down when a enemy attacks the FPS Character Controller, in the tutorial they just talk about the health bar going down when the space bar is pressed, or the health bar changing color's as it goes down. Can you make this KZread tutorial for me, I am sure it will help lots of other people with making their video games? So do I need to make a script for the health bar, and the zombie attack only, and the FPS Character Controller (the player) is not included in script of the health bar going down when the zombie attacks my player? So its just zombie, and health bar that is needed when you write a script for a health bar to go down?

  • @milanreusch4570
    @milanreusch45707 ай бұрын

    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

    7 ай бұрын

    It needs to be [SerializeField] without the "D" :)

  • @ahsanshah7373
    @ahsanshah73732 жыл бұрын

    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! :)

  • @RaceSmokie
    @RaceSmokie5 жыл бұрын

    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! :)

  • @zaidtaweel2542
    @zaidtaweel25424 жыл бұрын

    underrated channel

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    Thanks man! :)

  • @publicstaticvoid3224
    @publicstaticvoid32245 жыл бұрын

    Good job. You can also turn off the mesh renderer to give the player the illusion of it being automatic.

  • @ahmedsleem81
    @ahmedsleem815 жыл бұрын

    Very Useful tutorial, short simple and yet very very useful

  • @mustachebutter
    @mustachebutter4 жыл бұрын

    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! kzread.info/dash/bejne/nZqMttx6kZytZMo.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.

  • @pppparanoidddd
    @pppparanoidddd5 жыл бұрын

    Could you do a door tutorial?

  • @SpeedTutor

    @SpeedTutor

    5 жыл бұрын

    I'll see what I can do! :)

  • @diaryofarobot
    @diaryofarobot11 ай бұрын

    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

    11 ай бұрын

    Great to hear it, my friend. Good luck! :D

  • @TheBlackbirdii
    @TheBlackbirdii5 жыл бұрын

    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 ?

  • @ahmadelashi3944
    @ahmadelashi39445 ай бұрын

    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?

  • @Snikabarz
    @Snikabarz3 жыл бұрын

    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!!!

  • @IAmirb-ej8vu
    @IAmirb-ej8vu8 ай бұрын

    Awesome ❤❤

  • @SpeedTutor

    @SpeedTutor

    8 ай бұрын

    Thanks for watching, how did you find me?

  • @davidmiller6452
    @davidmiller64523 жыл бұрын

    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?

  • @CraftyMaelyss
    @CraftyMaelyss4 жыл бұрын

    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?

  • @Kingstantin
    @Kingstantin Жыл бұрын

    Hm for some reason it doesn't like this part: [SerializeField] private Animator myAnimationController; it seams not knowing [SerializeField]. What is wrong?

  • @SpeedTutor

    @SpeedTutor

    Жыл бұрын

    Is there an error before or after that?

  • @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! kzread.info/dash/bejne/Z4ZhxraImNqnnpc.html

  • @ZenaGreen
    @ZenaGreen4 жыл бұрын

    PERFECT

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    Great to hear it, thanks for watching! :)

  • @inboraStudio
    @inboraStudio2 жыл бұрын

    thank you so much bro love you from india

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    You're very welcome, my friend! :)

  • @0aleolijest678
    @0aleolijest6783 жыл бұрын

    Thanks

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    You're very welcome! :)

  • @OdinGamingMC
    @OdinGamingMC3 жыл бұрын

    Did I write something wrong? My code is just straight up not working. There are no errors or warnings when launching the game. I can't see if I wrote something wrong, please help. public class Test : MonoBehaviour { [SerializeField] public Animator myAnimationController; private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { myAnimationController.SetBool("playerNear", true); } else { myAnimationController.SetBool("playerNear", false); } } }

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    Do you have any errors?

  • @theknard3202
    @theknard32023 жыл бұрын

    thanks

  • @SpeedTutor

    @SpeedTutor

    3 жыл бұрын

    You're very welcome! :)

  • @TajuSingh
    @TajuSingh3 жыл бұрын

    Great

  • @elbladel
    @elbladel4 жыл бұрын

    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! :)

  • @nobody_there_
    @nobody_there_5 ай бұрын

    You forgot something... when i clic on conditions, it says "Parameter does not exist in Controller".... so ?

  • @TheAlvar0x
    @TheAlvar0x4 жыл бұрын

    When I place the object in the Animator space in inspector and I play the button to play the game, the space gets empty again. I dont know why does it happen... please help me

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    I'm not sure, any errors?

  • @TheAlvar0x

    @TheAlvar0x

    4 жыл бұрын

    @@SpeedTutor the problem was that I put "anim = GetComponent();" when it resets the Animator component when play the game. i've fixed it

  • @alielsayed8078
    @alielsayed80784 жыл бұрын

    i cant thank you enough

  • @SpeedTutor

    @SpeedTutor

    4 жыл бұрын

    I'm glad to hear it! :)

  • @TTailled
    @TTailled2 жыл бұрын

    script class cannot be found.. I guess there's no easy way around this.. Also even with the default state set as entry, the animation still plays...

  • @SpeedTutor

    @SpeedTutor

    2 жыл бұрын

    Is the script name the same as your class name?