Playing Animation on Trigger in Unity

Поделиться
HTML-код
  • Опубликовано: 26 янв 2025

Комментарии • 302

  • @SpeedTutor
    @SpeedTutor  4 года назад +14

    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 3 года назад +38

    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  3 года назад +4

      That's a heroic tip, thanks for sharing my friend! :D

  • @namdol_
    @namdol_ 3 года назад +22

    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 года назад +2

      I do have another animation tutorial which can make this happen in a line of code which might also help you! :)

    • @namdol_
      @namdol_ 3 года назад +1

      @@SpeedTutor Awesome! Will give it a watch.

  • @SpaceDodo
    @SpaceDodo 5 лет назад +66

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

  • @elisabethmarx7940
    @elisabethmarx7940 3 года назад +9

    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 лет назад +7

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

  • @bluemodize7718
    @bluemodize7718 2 года назад +1

    Thanks after 1 day of research finally found a good toutorial

    • @SpeedTutor
      @SpeedTutor  2 года назад +1

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

  • @notjohn321
    @notjohn321 4 года назад +3

    Thank you so much!! i found this tutorial after two days of trying to make a working elevator and it made it work!!

  • @schindoneer198
    @schindoneer198 3 года назад +1

    @SpeedTutor
    How can i do this on click?

  • @cubingle6843
    @cubingle6843 4 года назад +2

    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 4 года назад

      set the desired final state of obj in another state and keep it as the last one in your animator

  • @joythedisigner
    @joythedisigner Год назад +1

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

  • @diaryofarobot
    @diaryofarobot Год назад +2

    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

  • @breaola2470
    @breaola2470 4 года назад +1

    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!

  • @KeiNovak
    @KeiNovak 5 лет назад +2

    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.

  • @milanreusch4570
    @milanreusch4570 Год назад +1

    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  Год назад

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

  • @Snikabarz
    @Snikabarz 4 года назад +1

    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  4 года назад +2

      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 4 года назад

      @@SpeedTutor dude that just saved my life, thanks. That should speed up the developing process quite a bit

    • @SpeedTutor
      @SpeedTutor  4 года назад

      I'm happy to hear it! :) You watched the older one?

    • @golflefleur2767
      @golflefleur2767 4 года назад

      @@Snikabarz which video was it? i really need it!!!

  • @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 4 года назад

      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.

  • @nickw6969
    @nickw6969 2 года назад +1

    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  2 года назад

      You can also check out my newer tutorials on this, which may help you out even easier! :)

  • @soulstriker6
    @soulstriker6 2 года назад +1

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

  • @greeng448
    @greeng448 2 года назад +2

    It work very well on my zombie animation thank you

  • @davidmiller6452
    @davidmiller6452 3 года назад +1

    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 года назад +1

      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?

  • @shivc03
    @shivc03 Год назад

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

  • @BLOTROPS
    @BLOTROPS 3 года назад

    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  3 года назад

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

  • @ragnaesports5519
    @ragnaesports5519 4 года назад

    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  4 года назад

      I'm not really sure as this isn't something I've looked into before :(

  • @acikgozemre
    @acikgozemre 3 года назад +1

    Thank you so much! I was using to stop trigger with else but now realized I d had to exit :)

    • @SpeedTutor
      @SpeedTutor  3 года назад +1

      Glad I could help! I do have another tutorial on playing animations on trigger, which is easier and more recent! :)

    • @acikgozemre
      @acikgozemre 3 года назад +1

      @@SpeedTutor Thank you i will watch it

  • @ahmadelashi3944
    @ahmadelashi3944 11 месяцев назад +1

    Thanks so much. I was about to quit. New sub!!

    • @SpeedTutor
      @SpeedTutor  11 месяцев назад

      Haha! You're very welcome, I'm glad you didn't quit. What are you creating?

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

  • @MysteryUnclear
    @MysteryUnclear 2 года назад

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

  • @zaidtaweel2542
    @zaidtaweel2542 5 лет назад +2

    underrated channel

  • @therealHorto
    @therealHorto 6 лет назад +3

    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  6 лет назад

      What sort of things do you struggle to animate?

  • @SpyroDragon
    @SpyroDragon 2 года назад

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

    • @SpeedTutor
      @SpeedTutor  2 года назад

      Does the autofill work for you, nromally?

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

  • @leoisforevercool
    @leoisforevercool 3 года назад +1

    Thank you, you hero and saint of a man

    • @SpeedTutor
      @SpeedTutor  3 года назад

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

  • @kaleemfarooq2190
    @kaleemfarooq2190 4 года назад +1

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

  • @saraschroder7523
    @saraschroder7523 2 года назад

    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  2 года назад

      I'm not really sure about that one, can you purposely slow the animation down?

  • @robertmcdonald5785
    @robertmcdonald5785 2 года назад

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

  • @pppparanoidddd
    @pppparanoidddd 6 лет назад +3

    Could you do a door tutorial?

    • @SpeedTutor
      @SpeedTutor  6 лет назад +3

      I'll see what I can do! :)

  • @marcusbean6658
    @marcusbean6658 4 года назад +1

    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?

  • @yeevon3852
    @yeevon3852 4 года назад +1

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

  • @Goggalor1990
    @Goggalor1990 3 года назад +2

    Works great, thank you!

  • @valeriopavan
    @valeriopavan 4 года назад +1

    Just a curiosity in the script: Why did you use [SerializeField] and private, instead of a public variable? :)

    • @SpeedTutor
      @SpeedTutor  4 года назад +1

      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!

  • @E-0n-exe
    @E-0n-exe 4 месяца назад

    5 years later. Using unity 2022.3.43f1
    So i dont know if the version has updated and changed so much that this isnt useful anymore
    However
    I made my own custom tag of "NPC" instead of player, because the Npc's should not have access to the rest of the luxories and features that the "player" tag has access to.
    Any time any object with this Custom tag enters an animation trigger. Nothing happens. even after using Debug.Log to see if the trigger is triggered. It seems nothing with any other tag works.
    I do make sure that it :
    if(other.CompareTag("NPC"))
    {
    Debug.Log("Collideractive");
    doorAnimationController.SetBool("openTrigger", true);
    }
    but nothing happens. Might you know why?
    Would it be better if I just remove the Compare tag entirely? and just use
    if(other)
    {
    do the thing
    }

  • @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 года назад +1

      That shouldn't happen, but I do have a tutorial which is updated from this. It's in the description which might help you! :)

  • @monsterboyx7076
    @monsterboyx7076 4 года назад +1

    i want to implement it on a moving a character

  • @Kingstantin
    @Kingstantin 2 года назад

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

    • @SpeedTutor
      @SpeedTutor  2 года назад

      Is there an error before or after that?

  • @CraftyMaelyss
    @CraftyMaelyss 5 лет назад +1

    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  5 лет назад +1

      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 5 лет назад

      @@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  5 лет назад

      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 5 лет назад

      @@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  5 лет назад

      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?

  • @TheAlvar0x
    @TheAlvar0x 4 года назад

    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

  • @SpeedTutor
    @SpeedTutor  3 года назад +1

    Playing Animation on Trigger (With one line of code): ruclips.net/video/kqBGg6Rme10/видео.html&

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

  • @adriantoth1230
    @adriantoth1230 3 года назад +1

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

  • @milan7689
    @milan7689 4 года назад +1

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

  • @nobody_there_
    @nobody_there_ 11 месяцев назад

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

  • @T3MPLE_
    @T3MPLE_ 4 года назад

    hey can you tell me how you made all of your text soo small for me its all so big that i dont have enough room any more
    pls help

    • @SpeedTutor
      @SpeedTutor  4 года назад

      What text are we talking about? Text in VisualStudio? (If so) Hold Ctrl + Scroll with your mouse wheel! :)

    • @T3MPLE_
      @T3MPLE_ 4 года назад

      @@SpeedTutor the text in unity

    • @SpeedTutor
      @SpeedTutor  4 года назад

      You can either increase your Windows 10 default scaling OR change Unity's text size in preferences. I have a video on that too! :)

    • @T3MPLE_
      @T3MPLE_ 4 года назад +1

      Ok thx
      Verry fast reply wow thx

    • @SpeedTutor
      @SpeedTutor  4 года назад

      No worries at all! :)

  • @ThirdMoveStudios
    @ThirdMoveStudios 6 лет назад

    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!

  • @ScilexGuitar
    @ScilexGuitar 4 года назад

    This is great but I was kind of hoping for how the "Trigger" parameter works, instead of the bool

    • @SpeedTutor
      @SpeedTutor  4 года назад

      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 4 года назад

      @@SpeedTutor Thank you! Will watch the video but I think I got it to work anyways :)

    • @SpeedTutor
      @SpeedTutor  4 года назад

      No worries at all! :)

  • @Goblexter
    @Goblexter 5 лет назад +2

    You might want to increase the font size for your videos. Can't see shit unless watching in fullscreen.

  • @charlesferry9465
    @charlesferry9465 5 лет назад

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

  • @dreamescence
    @dreamescence 5 лет назад +1

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

  • @gmangman123
    @gmangman123 2 года назад +1

    good tutorial again my friend!

    • @SpeedTutor
      @SpeedTutor  2 года назад +1

      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 2 года назад

      @@SpeedTutor take look my demo! ruclips.net/video/5R-dTOhwAn4/видео.html

  • @elbladel
    @elbladel 4 года назад

    It is working, thanks! But what if I don't want the animation to be a loop?

    • @SpeedTutor
      @SpeedTutor  4 года назад +1

      You can select the animation itself and untick "LoopTime" I think!

    • @elbladel
      @elbladel 4 года назад +1

      @@SpeedTutor It worked! Thank you so much!!!

    • @SpeedTutor
      @SpeedTutor  4 года назад +1

      Haha, no worries at all! :)

  • @OdinGamingMC
    @OdinGamingMC 4 года назад

    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);
    }
    }
    }

  • @StigDesign
    @StigDesign 6 лет назад +2

    Awsome to see you back with tutorial :D so this is the mecanic to activate animation state/StateMachine :)

    • @SpeedTutor
      @SpeedTutor  6 лет назад +1

      Thanks man! Good to hear from you again! :)

    • @StigDesign
      @StigDesign 6 лет назад +1

      @@SpeedTutor thank you:D

  • @ifredpingplay468
    @ifredpingplay468 3 года назад +1

    Thanks Worth it bro :) thanks for explaining this simple

    • @SpeedTutor
      @SpeedTutor  3 года назад +1

      I'm really glad you think so, thanks for coming along to check this out! :D

  • @anthonycollins7992
    @anthonycollins7992 5 лет назад +2

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

  • @Roxidom
    @Roxidom 2 года назад

    doesn't work anymore i can't add this to my controller 8:20

    • @SpeedTutor
      @SpeedTutor  2 года назад

      Are you sure you created the correct reference?

  • @snehasinghgaur9909
    @snehasinghgaur9909 2 года назад +1

    Thank you so much dude ❤

  • @AdAstra91
    @AdAstra91 3 года назад +1

    Many thanks m8 u helped me A LOT !!!

    • @SpeedTutor
      @SpeedTutor  3 года назад +1

      I'm glad you think so! I also have an updated tutorial which may help you out too! :) It's in the description.

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

  • @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 лет назад +1

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

  • @BitterTast3
    @BitterTast3 3 года назад +2

    I love you.

    • @SpeedTutor
      @SpeedTutor  3 года назад

      Ditto! Thanks for watching my friend! :D

  • @qtate78
    @qtate78 5 лет назад

    Any idea why I can't drag and drop my gameobj into the My Anim Controller slot? Whenever I go into the Hierarchy to select the gameobj and drag it over to the script it's got the infamous prohibited sign?

    • @SpeedTutor
      @SpeedTutor  5 лет назад

      Does the gameobject you're dragging in have a animator component?

    • @qtate78
      @qtate78 5 лет назад +1

      @@SpeedTutor Thank you first and foremost for the timely reply :D That allowed me to drop the gameobject into the MyAnimController variable slot, but the animation isn't working so I'm going to scrap the project and follow this amazing tutorial again. I know it's def a mistake on y end I just have to figure out what I'm doing wrong. As always keep up the amazing tutorials you're absolutely amazing bro!!!!

    • @SpeedTutor
      @SpeedTutor  5 лет назад +1

      Thanks man, very best of luck. Yes! Start from the beginning and see if you pick anything up, sometimes it's something some obnoxiously tiny! :)

    • @qtate78
      @qtate78 5 лет назад

      @@SpeedTutor Your method helped out a lot and I made good progress, the ONLY last issue I'm having now lol it the warning message in the console. The message states Parameter 'OpenChest' does not exist. UnityEngine.Animator:SetBool(String, Bool)…..When I open the animoator window and physically check the parameter the chest opens, but when I use my char to walk into the trigger I get that warning. Do you think it's my character or broken capsule collider I'm using for my char by chance? This is unfortunately my only issue Unity is so unforgiving lol.

    • @SpeedTutor
      @SpeedTutor  5 лет назад

      I do have another tutorial which talks about playing an animation and it doesn't use this process. I'll try and find it for you! :)

  • @babaganoosh1969
    @babaganoosh1969 6 лет назад

    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  6 лет назад

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

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

  • @ragnaesports5519
    @ragnaesports5519 4 года назад +1

    Thank you for this tutorial!

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

  • @noname6573
    @noname6573 5 лет назад

    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.

  • @CazeElite
    @CazeElite 5 лет назад

    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?

  • @UwuSwaggins
    @UwuSwaggins 2 года назад +1

    Increadibly healpful. Thank you!

    • @SpeedTutor
      @SpeedTutor  2 года назад

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

  • @TTailled
    @TTailled 3 года назад

    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  3 года назад

      Is the script name the same as your class name?

  • @turbocharged213
    @turbocharged213 6 лет назад

    how could I make the player press the e key once inside the collider to run the animation?

    • @turbocharged213
      @turbocharged213 6 лет назад

      this is my current code, but the code still doesnt work
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Open : MonoBehaviour {
      [SerializeField] private Animator myAnimationController;
      private void OnTriggerEnter(Collider other)
      {
      if (other.CompareTag("Player") && Input.GetKeyDown(KeyCode.E))
      {
      myAnimationController.SetBool("runclip", true);
      }

      }
      private void OnTriggerExit(Collider other)
      {
      if (other.CompareTag("Player"))
      {
      myAnimationController.SetBool("runclip", false);
      }
      }
      }

    • @SpeedTutor
      @SpeedTutor  6 лет назад

      Any errors because it looks like it should work?

    • @turbocharged213
      @turbocharged213 6 лет назад

      @@SpeedTutor no, I can run the code without the input getkeydown part and have it the same as yours with no problems, but when I try to add that bit it just doesn't function, but no errors. I have tried to make it display a message in the log within the if statement, but it dos not do anything. I have only started using unity about 2 weeks ago but have watched lots of tutorials and at least know the basics. Thank you for your help.

    • @SpeedTutor
      @SpeedTutor  6 лет назад

      Ah my bad, I know why. If you imagine that "OnTriggerEnter" will only run code once (When you collide with it). To actually do an input event you need a type of method that will be checking if you're instead the trigger at any point. One example you could create a boolean to be set to true when you're in the collider, then in an update method do the input event.
      But I'd say an easier way would be using "OnTriggerStay" rather than "OnTriggerEnter" - Which is similar to the update method (Checking every frame) but will only check if you're still inside the collider. I hope that helps you out! :)

    • @turbocharged213
      @turbocharged213 6 лет назад

      @@SpeedTutor Thanks a lot!! It works now.

  • @zulaiman2151
    @zulaiman2151 3 года назад +1

    Thanks bro, Really appreciate it.

    • @SpeedTutor
      @SpeedTutor  3 года назад

      That's no problem at all! :)

  • @xueniyu8187
    @xueniyu8187 5 лет назад

    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  5 лет назад +1

      Yes of course! :)

    • @xueniyu8187
      @xueniyu8187 5 лет назад +1

      @@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  5 лет назад

      Thanks very much! :) I really appreciate it!

  • @dkordy
    @dkordy 3 года назад

    Nice, you helped me. But I need a little more help and I can't find the answer anywhere, you are the closest to answering me, that's why I'm addressing you. I have a situation where I want my player to be able to use an animation attack only when he picks up a weapon. Before that no (before taking up wepons i want to only uses basic movements,after pick up wepons i want to be able to use attack animation) I don't know if you understand me and if so, would you answer me? Thanks!

    • @SpeedTutor
      @SpeedTutor  3 года назад

      You need a different set of states when you have weapons, it could be a different set of animations for the character that are activated when you pick one up. That's a very indepth question. You want to have something that switches states and even state machines with the animations.

  • @hlmrz
    @hlmrz 5 лет назад

    How can I Triggeranimetion when certain audio is playing ?

    • @SpeedTutor
      @SpeedTutor  5 лет назад

      Create a script which activates when an audio clip starts, then play the animation?

    • @hlmrz
      @hlmrz 5 лет назад

      @@SpeedTutor I am lack of exp. when it comes to coding if you are available, can you please send any example that I can change little bit

  • @activatewindowsgaming
    @activatewindowsgaming 4 года назад

    how do i only make the animation play once?

    • @SpeedTutor
      @SpeedTutor  4 года назад

      Select your animation and untick "Loop"?

    • @activatewindowsgaming
      @activatewindowsgaming 4 года назад

      @@SpeedTutor i did, and it still did it, it was just error in my code and i fixed it :)

    • @SpeedTutor
      @SpeedTutor  4 года назад

      Awesome, what was the error? Haha.

  • @paulrobinson5490
    @paulrobinson5490 6 лет назад +1

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

    • @SpeedTutor
      @SpeedTutor  6 лет назад

      Great to hear it, thanks for watching! :)

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

  • @inboraStudio
    @inboraStudio 2 года назад +1

    thank you so much bro love you from india

    • @SpeedTutor
      @SpeedTutor  2 года назад

      You're very welcome, my friend! :)

  • @karolledzinski710
    @karolledzinski710 4 года назад

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayAnotherAnimOnTrigger : MonoBehaviour
    {
    [SerializeField] private Animator myAnimationController;
    private void OnTriggerEnter(Collider other)
    {
    if (other.CompareTag("Player"))
    {
    myAnimationController.SetBool("ChangeAnimationTroley", true);
    }
    }
    }
    Can you please check .I needed only player with animation (moving troley) to hit the box and change his own animation to hit ....I tweak the scene a little bit but no chance to work it out. Pleae let me know if you have idea what I am doing wrong. Thank You.

    • @SpeedTutor
      @SpeedTutor  4 года назад

      Check out my recent tutorial on playing animations, it might be even easier for you! :)

    • @karolledzinski710
      @karolledzinski710 3 года назад

      @@SpeedTutor hmm... So many videos... Can You please give me link. Thank You

  • @BonBon-qt4xb
    @BonBon-qt4xb 4 года назад +1

    You're a life saver man, thanks a lot

    • @SpeedTutor
      @SpeedTutor  4 года назад +1

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

  • @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! ruclips.net/video/kfXTzAa9G4g/видео.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.

  • @handkey9451
    @handkey9451 6 лет назад

    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  6 лет назад +1

      I'll keep this in mind, thanks! :)

  • @publicstaticvoid3224
    @publicstaticvoid3224 5 лет назад +2

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

  • @ankush1880
    @ankush1880 5 лет назад +7

    Thank you, God bless you.

  • @i_amirb
    @i_amirb Год назад +1

    Awesome ❤❤

    • @SpeedTutor
      @SpeedTutor  Год назад

      Thanks for watching, how did you find me?

  • @EzXet
    @EzXet 2 года назад +1

    thank you so much bro

  • @GoroPvMRunescape
    @GoroPvMRunescape 5 лет назад

    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  5 лет назад +1

      When you destroy the trigger, make sure you to turn the bool to false!

  • @TheBlackbirdii
    @TheBlackbirdii 6 лет назад

    does should work with unity 2017 ? or specific to 2018 ? can you do one with timeline

    • @SpeedTutor
      @SpeedTutor  6 лет назад +1

      It would easily work with Unity 5 / 2017 / 2018 and onwards.

    • @TheBlackbirdii
      @TheBlackbirdii 6 лет назад

      @@SpeedTutor off topic any chance to make a tutorial how to add rumble when player get hit or enter a trigger ?

  • @Guesswho012
    @Guesswho012 Год назад +1

    Where is the script? for trigger

    • @SpeedTutor
      @SpeedTutor  Год назад

      It's right in the video :) Or I do have a tutorial to play animations in an even easier down in the description :)

  • @mrunmaymycode748
    @mrunmaymycode748 3 года назад +2

    Thank You So Much...

    • @SpeedTutor
      @SpeedTutor  3 года назад +1

      No problem at all, I do also have an even easier tutorial which you can checkout too! :D

    • @mrunmaymycode748
      @mrunmaymycode748 3 года назад +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  3 года назад +1

      Awesome! Glad I could help you out. Good luck with your projects! :D

    • @mrunmaymycode748
      @mrunmaymycode748 3 года назад +1

      @@SpeedTutor TYSM...‼😁