Using IMPROVED Animation Events in Unity

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 150

  • @git-amend
    @git-amend  2 місяці тому +14

    Happy Sunday! 🎉 Let's make an improvement on Unity's Animation Event system today! Check the repository for AnimationEvents from BlendTrees support as well.

  • @ZacharyYates
    @ZacharyYates 2 місяці тому +30

    This is the best unity channel on UA-cam.

    • @git-amend
      @git-amend  2 місяці тому

      Thanks for the kind words!

    • @reithaz_
      @reithaz_ 2 місяці тому

      word

  • @Yoraiz0r
    @Yoraiz0r 2 місяці тому +12

    Hey, I'm happy to see someone finally using StateMachineBehaviour! Would love to see you do a followup for everyone about extending ObjectPreview so those state machine behaviors can draw a preview of the animated character just like the Animator transitions do, without requiring modifying the scene character, and controlling that one's timeline.

    • @git-amend
      @git-amend  2 місяці тому +3

      Good idea. I actually thought about doing that too, but the video would have gotten a bit long. Something for the future!

    • @X1N30F
      @X1N30F 2 місяці тому

      @@git-amend Is this actually possible? I remember for one of the tools I made that I was not able to get a preview of an animation clip, ended up giving up in the end, it would have been a nice extra feature but if it actually a thing, I would love to go back and implement it!

    • @git-amend
      @git-amend  2 місяці тому

      @@X1N30F The preview window itself is doable with some effort. But, if you check the repository you'll find additional code for showing a blend tree animation in scene view that uses the Playable Graph (more functionality added after recording). Once you start making your own Playable Graph, you can do just about anything preview wise. Actually opening the preview window and using it requires using some reflection, but that window uses a similar technique.

    • @X1N30F
      @X1N30F 2 місяці тому

      @@git-amend thanks so much for getting back to me, I will definitely look into that and see how it goes! I might be able to just see what I could do to shoe in something for the preview window, since that's more so what I need rather than being in the scene view in any case I'm sure it will point me in the right direction.

  • @hotphe6723
    @hotphe6723 2 місяці тому +13

    I found it inconvenient to add animation events in AnimationEditor, so I created an animation wrapping class using ScriptableObject. I now see there's a way to add it directly to the state. Thank you for the helpful video.

    • @git-amend
      @git-amend  2 місяці тому +1

      You're welcome! Thanks for watching!

    • @TheKr0ckeR
      @TheKr0ckeR 28 днів тому

      I'd also like to hear that how your SO object wrapping class is helping the situation, do you still use keys etc?

  • @indianapapi
    @indianapapi 2 місяці тому +1

    I just discovered this channel, and the comments I see are very positive. I see why, bro. This right here is the truth. I am now a faithful subscriber!

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks so much! Welcome to the channel-I’m glad you’re enjoying the content!

  • @herpenderper
    @herpenderper 2 місяці тому +2

    Honestly, having watched a ton of youtube tutorials over my gamdev career, I can't think of better educator than you! Well explained, to the point, easy to follow. A+ 👌

    • @git-amend
      @git-amend  2 місяці тому +1

      Wow, thanks! I appreciate the kind words!

  • @DrGroo
    @DrGroo 7 годин тому

    👍 Magnificent. Great to see a video on this sophisticated a level of unity resulting... And one that makes it feel quite approachable.

    • @git-amend
      @git-amend  4 години тому

      Much appreciated! I aim to make complex topics easier to grasp.

  • @nhatlinhtran3575
    @nhatlinhtran3575 2 місяці тому

    Great content as always! Thank you for consistently creating such amazing videos every week!

  • @metaling278
    @metaling278 2 місяці тому

    video is gold. appreciate everything you do for us :D

    • @git-amend
      @git-amend  2 місяці тому

      I appreciate that!

  • @kpm25
    @kpm25 13 днів тому

    Thanks Adam, This was quite full on but well worth the effort to go through! Cheers

    • @git-amend
      @git-amend  13 днів тому

      You're welcome, glad it was useful!

  • @AlexanderSholk
    @AlexanderSholk 2 місяці тому +1

    I'm just watching the whole video in one gulp! Very clear, without water and at a high level! I can't wait for you to start coding shaders;)

  • @jb-lj8cj
    @jb-lj8cj 2 місяці тому +1

    Just starting to work on my first game in unity. Definitely a challenge with a full time job but your tutorials are fantastic!
    Was just looking into animations as well 😊

  • @stephanedurette5785
    @stephanedurette5785 2 місяці тому +1

    git-amend reached into my brain and made a video helping with what I was currently struggling with.

    • @git-amend
      @git-amend  2 місяці тому

      Haha, nice glad to hear that!

  • @Haze_E1
    @Haze_E1 Місяць тому

    perfect for what im doing keep it up, unity needs to hire you, best tutorials around

    • @git-amend
      @git-amend  Місяць тому

      I appreciate that! Maybe one day they will!

  • @谢威-k3d
    @谢威-k3d 2 місяці тому

    Definitely the best channel for those who want to learn intermediate and high level developing skills!
    One thing I don't like about unity's state machine behavior is that, if there are two states blending between each other, the second state's OnStateEnter will actually be called before the first state's OnStateExit, this can cause bugs when script logic is highly depending on the animation's begin and end. (luckily, thx for git-amend's better state machine video, I extend that one to split the game logic and animation, really save my life)

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks so much for the comment! You're absolutely right-Unity's state machine can sometimes cause issues with overlapping `OnStateEnter` and `OnStateExit`, which is why splitting game logic from animation, as you've done, is such a great solution for avoiding those bugs. Thanks for sharing that!

  • @SomeKrnDude
    @SomeKrnDude 2 місяці тому

    I am grateful for all the information you've given me but I can't help but be discouraged at the same time.
    You are insane. Every video I watch there is an ocean of information to take in. I was already satisfied at 4:50, but clearly you were not, and you went on to adjust InspectorGUI and HumanBodyBones. I didn't even KNOW that HumanBodyBones even existed. I didn't even know that I wanted all this before you showed it, and now it feels like a requirement.
    I thought knowing couple of common design patterns and a decent understanding of SOLID was enough for me to code efficiently, but there is so much knowledge out there that I don't know.
    If I'm trying to break into the video games industry, is this the level of Unity/C# (in your other videos) understanding I need to be competitive? Have I been doing nothing the past year?
    panik

    • @git-amend
      @git-amend  2 місяці тому +1

      Just keep in mind that the career of the game dev / software engineer is one of constant learning. You (and I) will never know everything, so just keep on learning new things every day! There is always more...

    • @SomeKrnDude
      @SomeKrnDude 2 місяці тому +1

      ​@@git-amend Will do... Just in case I didn't make it known enough, thank you so much for these high quality videos.
      I didn't know functional programming existed in C# until you showed it in your channel.
      I didn't know that you could edit the inspector until you showed it in your channel.
      I didn't know about the 'is a' / 'has a' relationship for composition vs inheritance until you showed it in your channel.
      Even though I am not at the level of mastery to fully understand/utilize all these concepts, this is the most helpful Unity channel for me BECAUSE it shows me what I don't know. I wish the best for you.

  • @henrikekholm6437
    @henrikekholm6437 2 місяці тому +2

    holy manoly, these was the one I needed just as this moment

  • @dustintaub
    @dustintaub 2 місяці тому

    This is fantastic and very timely in my case. This week, I've literally been going though and doing all those annoying tasks to make animation events manually.

    • @git-amend
      @git-amend  2 місяці тому

      Awesome, glad to hear that!

  • @dev_samo
    @dev_samo 2 місяці тому +1

    Brilliant as always !

    • @git-amend
      @git-amend  2 місяці тому

      Thank you! Cheers!

  • @prometheus1100
    @prometheus1100 2 місяці тому

    Your channel is a godsend. Thank you for sharing your expert knowledge.

    • @git-amend
      @git-amend  2 місяці тому +1

      Thank you so much for the kind words! I’m really glad the content is helping you out-more great stuff is on the way!

  • @silchasruin4487
    @silchasruin4487 2 місяці тому

    Thank you so much for this, cumbersome is too polite a word I would use for Unity's animation system. I used AnimatorStateInfo to keep track of when animations were at varying points for things such as attacks or when I wanted logic to transition animations because Unity's Animation Event system either was too buggy or didn't respond at all when you wanted split second triggers. Love the addition of the custom editor!

    • @git-amend
      @git-amend  2 місяці тому +1

      Thank you! I agree, AnimatorStateInfo is underrated for things like that!

  • @TheKr0ckeR
    @TheKr0ckeR 16 днів тому +2

    What about loop animations? Since we use hasTriggered, if the animation is looped like "spinning animation", if we put and event start and end of it, it will only work when the animation is changed to some other state.So it wont constantly invoke the event while the animation is in loop mode

    • @TheKr0ckeR
      @TheKr0ckeR 16 днів тому

      To solve this; I have added previousValue, if we pass the threshold, i reset the bool value.
      public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
      {
      float currentTime = stateInfo.normalizedTime % 1.0f;
      if (activateOnLoop)
      {
      if (currentTime < _previousNormalizedTime)
      {
      _hasTriggered = false;
      }
      }

      if (!_hasTriggered && currentTime >= triggerTime)
      {
      NotifyEvent();
      _hasTriggered = true;
      }

      _previousNormalizedTime = currentTime;
      }

    • @git-amend
      @git-amend  16 днів тому

      Seems like a good solution.

  • @CloverJump
    @CloverJump 2 місяці тому

    Thank you so much for teaching me this!

    • @git-amend
      @git-amend  2 місяці тому

      You are so welcome!

  • @INeatFreak
    @INeatFreak 2 місяці тому +4

    This is great! I always hated how Unity handled these animation events, not only setting it up was painful but also you had no way of knowing before hand if that clip had an event inside it. You could easily forget when changing animation clips for better ones actually to setup the events again. Storing it within the Mechanic State Machine is definitely a better approach.

    • @git-amend
      @git-amend  2 місяці тому

      Yes, my sentiments exactly!

  • @fleity
    @fleity 2 місяці тому

    Nice! Reminds me a bit of timeline signals too. I remember doing something similar like this a few years ago. Basically invoke unity events whenenver a state starts / stops etc. Seeing you write the editor tool code for this is very useful btw. I write a lot of editor code but just as often I think urgh editor stuff is so convoluted and badly documented, thanks for the learning opportunity.

    • @git-amend
      @git-amend  2 місяці тому

      Nice, I haven't heard anyone mention signals in a long time! Connecting events to the states instead of the clips seems much more intuitive.

  • @romrom_13
    @romrom_13 2 місяці тому +1

    Cool and useful video - as always)
    I tried this approach and discovered two interesting things:
    1) The script can be slightly modified so that it takes all the sub state machines that are found in the main state machine - I played around a bit and it seems that something has worked out for me, which means that it will work for others as well)
    2) I wonder what you are thinking of doing with the mixing trees, since several animations are used there and you can't add behavior to them, unfortunately...
    But I'll say it again - very, very cool video - thank you!

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks for the comment! I'm going to continue developing the script to handle some other things - handling substates is a good idea. For the blend trees, instead of normalizing a time, we can use the normalized weight param, and that part isn't too tricky - but displaying a preview is a little more difficult since there is no exposed method we can use for that. It will likely have to depend on some reflection. If I come up with a good solution for that, I'll be updating the repository.

    • @TonyWilcock80
      @TonyWilcock80 2 місяці тому

      How did you modify the script? Unfortunately, most of my animations are in sub state machines and it wont work.

  • @nightonmars
    @nightonmars 2 місяці тому

    Man, Christmas came early this year 😄Thank you!

  • @LeoOB97
    @LeoOB97 2 місяці тому

    This is really helpful, i tried a lot of stuff to avoid using the default animation events but i never thought of this, StateMachineBehaviors are so overlooked

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks for the comment, I agree!

  • @mananzi9907
    @mananzi9907 Місяць тому

    This is incredible! I was wondering if you had any ideas on how to handle Animation Override Controllers, and overriding the animation events to work with this set up?

    • @git-amend
      @git-amend  Місяць тому +1

      That is a problem I haven't tackled yet. If I do, I'll make a video about it (or update the repository, make sure to enable notifications on the repo updates).

  • @IconGamesBR
    @IconGamesBR 2 місяці тому

    Thank you! Unity anim events in 2021 (what I'm using here) is a mess and this just saved my day!

    • @git-amend
      @git-amend  2 місяці тому +1

      Awesome, glad to hear that!

  • @atheroymis5523
    @atheroymis5523 2 місяці тому

    Nice, just discovered the channel and really enjoyed watching the videos. One thing I noticed in the latest 2 tutorials is that the top play bar inspector is changed. I tried to do that once but everywhere it was saying that specific editor part is locked to modification.

    • @git-amend
      @git-amend  2 місяці тому +1

      Awesome, glad to hear that. Check out the Time Scale Toolbar Free asset in the video description. If you download that, first of all it's great to use, but it also has an Editor script you can analyze called 'Toolbar Extender' to start making your own customizations.

    • @atheroymis5523
      @atheroymis5523 2 місяці тому

      @@git-amend Thanks will check it out

  • @notagamedev5494
    @notagamedev5494 2 місяці тому

    The epitome of excellence.

  • @DarthBiomech
    @DarthBiomech 2 місяці тому +2

    This is great, though there's a caveat that in some scenarios, events being tied to a specific animation file is actually _very_ useful. You can use one animator with several different NPCs with different animations, or like in my case, I've made a generalized sub-animator layer for handling weapons and items use, and what and when they activate their effects or sounds is determined by the animations they use... With script method you'd need to bake every single option into the animator, and clone animator for every new NPC, which immediately will make making edits to the animators a pain.
    My only gripe with the stock Animation Events is that they're gone when you re-import the animation.
    I wonder if it's possible to move this custom list of animation events into a separate external scriptable object and make it a dictionary of the animation files?

    • @git-amend
      @git-amend  2 місяці тому +1

      That's an interesting scenario. And also good to point out that they're gone after re-import. An approach of having a registry or dictionary might be one way to solve that, I'll have to give it a try as more features are added.

  • @НикитаМордик-к8ф
    @НикитаМордик-к8ф 2 місяці тому

    So useful feature, thanks))

  • @midniteoilsoftware
    @midniteoilsoftware 2 місяці тому

    I wish I'd known about this before I made my "footsteps" video in my Music and Sound Effects series. I did my events the old-fashioned way :)

    • @git-amend
      @git-amend  2 місяці тому +1

      Ah well, always more than one way to skin a cat!

  • @puretrack06
    @puretrack06 2 місяці тому +1

    You about to have me redo my entire animation system

    • @git-amend
      @git-amend  2 місяці тому

      Haha! I hope that's not a lot of work!

    • @puretrack06
      @puretrack06 2 місяці тому

      @git-amend I've been using animation events on the fbx Importer. Setting up the timing has been a pain in the ass. This is going to be a pain and a lot of time to do it but it's definitely worth it

    • @git-amend
      @git-amend  2 місяці тому +1

      Just do a couple and see how it's working for you first!

  • @jumpkut
    @jumpkut 2 місяці тому

    Great idea and execution!

    • @git-amend
      @git-amend  2 місяці тому

      Thank you! Cheers!

  • @SeriousNeko
    @SeriousNeko 2 місяці тому

    StateMachineBehaviors are pretty convenient when you remember they exist. I used them to make Animator play Timeline clips before I switch to Animancer plugin.
    I wish Unity just improved Timeline editor so it works more in line with Animator - support editing multiple timeline clips, not requiring Playable Director, being more convenient in general.
    Timeline allows to do much more things in more convenient ways, including stuff like in this video. Can wrap your read-only animation clips in timeline clips and it will work just fine. I hope new Dots animation system will solve this issue.

    • @git-amend
      @git-amend  2 місяці тому

      Hm, very interesting. I hope the same for the DOTS animation system.

  • @herbert9039
    @herbert9039 2 місяці тому

    very helpful, thank you

  • @TheKr0ckeR
    @TheKr0ckeR 28 днів тому

    You could've sold this as an asset for like 39.99 but not only you are giving it for free & and explaining every step... You are incredible man, to this community. I admire you. What would we do for eventName variable without strings? Since strings are easily mistyped, maybe enums? Or AnimationEventData SO reference instead of strings so that we can use it its name? Would it be overengineering.. IDK. Btw i couldnt see what we exactly changed on Animation Event property drawer. Seemed same to me as visually on the end.

  • @ahsansharif6962
    @ahsansharif6962 2 місяці тому

    i love it , it is very nice but i have one question what if i want to trigger same event multiple times in the same animation for example footsteps in walking animation

    • @git-amend
      @git-amend  2 місяці тому +2

      You can approach this in a few ways. The easiest will be to add an additional State Behaviour component for each event you want (so one for each step). Additionally, I would extend the editor to make the circuit breaker optional because your animation will probably be a looping one, so you could expose a checkbox to the inspector to allow for that and update the code slightly.
      Alternatively you can extend the component to handle multiple events at once, which isn't too challenging but remember to add some extra functionality to the preview to make it display correctly depending on which slider you are adjusting.

  • @razzraziel
    @razzraziel Місяць тому

    Thank you! I think it would be better to have multiple events on event state component. That way more than one events on different part of the same animation can be fired. Or multiple components on same animation would do the same job?

    • @git-amend
      @git-amend  Місяць тому

      Feel free to extend this example any way you see fit!

    • @TheKr0ckeR
      @TheKr0ckeR 28 днів тому

      Cant you just add another component? Since both component will call the receiver method in different time, it would still notify.

  • @nickreinstein4122
    @nickreinstein4122 2 місяці тому

    As others have pointed out, the Unity Animation Event system is hard to work with and is immensely cumbersome when animation clips need to be updated. Your solution seems fantastic and Unity should pay attention.
    I'm curious about the efficiency of this approach as the number of event state behaviors on a clip increases and the number of animated objects that handle events like this increases. Do you have any insight on if your solution is more or less efficient at runtime?

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks for the comment. This approach should be highly efficient at runtime for most use cases. As the scale increases, especially with hundreds or thousands of objects, it may require further optimization, but it’s unlikely to introduce significant performance issues in smaller-scale projects. I'll continue to optimize it as I think of improvements, or others suggest them. The only real cost is getting a reference to the Receiver component, which is minimal but could be optimized. In fact, I think I'll start by caching it OnStateEnter, but we could also use a registry of some kind to optimize further.

  • @derbabonennt8876
    @derbabonennt8876 2 місяці тому

    Could you extend on this topic and make a crossover with the Playable series?
    If I am not mistaken it should be possible to create a Scriptplayable with the functionality to call an Event on a specified Timing - the challenge here is to make the event previewable and "user friendly" to work with. because you dont have an animator controller window in the playable work-context.

    • @git-amend
      @git-amend  2 місяці тому +1

      Not a bad idea. I'll look into what's possible. Thanks for the comment!

  • @luanferreira-dev
    @luanferreira-dev 2 місяці тому +1

    I use a lot of animation events in my game so i was really sicked to see this, sadly this doesnt really work when you use animator controller overrides and each character that overrides that animator has their triggers at different times... Would be cool to see a solution that covers this case

    • @git-amend
      @git-amend  2 місяці тому +1

      Yes, someone else mentioned this. I'll have a look and see what can be done.

    • @nickreinstein4122
      @nickreinstein4122 2 місяці тому

      @@git-amend Does the recent change made to the git repo address this "animator controller override" issue at all?

  • @ClayManLanDay
    @ClayManLanDay 2 місяці тому

    Nice video!
    May I request one on authoring cutscenes (Playable Director + timeline?). It has been a pain int the ass when it uses navmeshed and animator controller

    • @git-amend
      @git-amend  2 місяці тому

      Thanks for the suggestion! I’ll keep that topic in mind-working with NavMesh and Animator Controllers in Timeline certainly has its challenges, and a walkthrough could be helpful.

    • @ClayManLanDay
      @ClayManLanDay 2 місяці тому

      @@git-amend Nice! That would be awesome!
      There is an official repository where there are examples for this. Sadly, the timeline API it uses is badly documented (or not enough "straight to the point" for my ADHD :'D)

  • @owencoopersfx
    @owencoopersfx 2 місяці тому

    Nice. Definitely better than the vanilla animation event system!

  • @damonfedorick
    @damonfedorick 2 місяці тому +2

    Nice!

    • @git-amend
      @git-amend  2 місяці тому +1

      Thank you! Cheers!

    • @damonfedorick
      @damonfedorick 2 місяці тому

      would this solution be something that could go into the unity-utils? the animator is a built in to unity.

    • @git-amend
      @git-amend  2 місяці тому +2

      @@damonfedorick I think I will keep this stand alone, at least for now. There are several improvements that can still be made: handling Animator Overrides and Layers, as well as support for passing parameter values as well. And possibly handling blend trees.

    • @damonfedorick
      @damonfedorick 2 місяці тому

      @@git-amend are you hoping for Open source to handle those new features? or will you end up re-covering it in another video ?

    • @git-amend
      @git-amend  2 місяці тому +2

      Haven't decided yet. The parameters is easy, so is layers. Overrides and Blend trees will take some doing.

  • @isleeg
    @isleeg 2 місяці тому

    The animation preview doesn't work when I tried it with a synth character and with the RPG Tiny Hero Duo characters. It works fine when using the RobotKyle.

    • @git-amend
      @git-amend  2 місяці тому

      Try commenting out 'AnimationMode.StopAnimationMode();' in the PreviewAnimationClip, maybe it's getting turned off prematurely.

  • @muhammadzubairirshad6724
    @muhammadzubairirshad6724 2 місяці тому

    By Watching this Video i am through i am doing wrong with animation events
    Thank you Soo much

    • @git-amend
      @git-amend  2 місяці тому

      Awesome! So happy the video helped you out! Keep animating and have fun with it! 🎉

  • @ИванЛашин-и7и
    @ИванЛашин-и7и 2 місяці тому

    Nice. But I have question:
    What wil be if i try use few AnimationEventReceiver on same animator state? Will collision be with prevew buttons?
    In total, it is interesting solution.

    • @git-amend
      @git-amend  2 місяці тому

      Well, the AnimatorEventReciver goes on the GameObject in the scene, but you must mean the StateMachineBehavior class. This works fine with multiple instances, but if you enable 2 Preview buttons at once, only the first one you activated will show the preview in the Scene view. You could add some extra code that would disable the other buttons if you wanted, or just use them one at a time.

  • @FeastTheSenses
    @FeastTheSenses 2 місяці тому +2

    I used this approach as well - I liked it but it has 1 massive issue: It doesn't work with animator override controller, so I had to give it up and go back to putting events on animations directly.
    Unity has a very flawed animation system.

    • @git-amend
      @git-amend  2 місяці тому +1

      Interesting, I'll have to look into that a bit more.

  • @あれくす
    @あれくす Місяць тому

    I get an error, "the playable graph is null." Why?

  • @OneMoreQuestDev
    @OneMoreQuestDev 28 днів тому

    Love the channel. It has helped me a lot both with work and my own projects. There is one down side to this approach it ties the event to the Mecanim state. For most cases that is fine, but if you are dynamically adding your animations this dose not work. You can solve this with and make it compatible with your other one shot animation system by adding a "info" event to your animations and a empty "info" method to your animation controller script. Then add a ScriptableObject in the object field in the animation event. When the clip is played grab the object off the clip and use whatever data you need. This is useful for dynamic combo systems, or letting a controller know how much time they have to be in position for an attack/precise animation.

  • @eyellen
    @eyellen 2 місяці тому +1

    It's a shame that we have to do such simple things ourselves, while Unity should have done it. I think the community has written more tools for Unity than the Unity itself.
    Btw nice video, I like how you implement such a useful things.

    • @git-amend
      @git-amend  2 місяці тому +1

      Thanks! You might be right!

  • @littledreamergames
    @littledreamergames 2 місяці тому

    Unity is vast, so not everyone knows this, but you can add events to animations that import with the fbx. Just click the fbx asset, click the Animation button at the top of the inspector, then scroll down to Events and add your events to the timeline. Regardless, and as always, great video!

    • @git-amend
      @git-amend  2 місяці тому +2

      Thanks for the comment! That's a good thing to point out, but it still tightly couples your events to an Animation Clip. Your Animation Clip will always have the same events attached to it everywhere you use it. Separation of concerns is the main advantage with a system like this video.

    • @littledreamergames
      @littledreamergames 2 місяці тому

      ​@git-amend your approach and implementation is very much appreciated.

  • @Danyanyanyanya
    @Danyanyanyanya 2 місяці тому

    Cool thing, but events didn't invoke when triggerTime is 1 or very close to 1

    • @git-amend
      @git-amend  2 місяці тому +1

      Well, at 100% there are no more frames in the clip to process. Can restrict the Range if that helps you, or even better would be to fire the event in OnStateExit if you need it to be at the very end of the clip (for non-looping clips)

  • @robb929
    @robb929 2 місяці тому +1

    The worst thing about Unity animation events is the use of magic strings. I think it's better to replace them with enums.

    • @git-amend
      @git-amend  2 місяці тому

      Yes, not a bad idea at all.

  • @ANU_CHEEKI_BREEKI
    @ANU_CHEEKI_BREEKI 2 місяці тому

    how about create event in Animation importer? already preview there. And no need to do any extra work

    • @git-amend
      @git-amend  2 місяці тому +1

      I want to associate events with animator states for an improved workflow where I have full control and am not locked into what's set in the animation itself - and I want it to be extensible to handle more options in the future.

    • @puretrack06
      @puretrack06 2 місяці тому +1

      The challenge comes when you have multiple events per animation. I am working on a hack and slash DMC like game. Each attack animation has VFX event, SFX event, Start/stop damage events, Start/Stop Invincible events at minimum. All of these can added in importer however they start to become a pain when they overlap one another.

  • @SeverskiyS
    @SeverskiyS 2 місяці тому

    And you can click on fbx file and add animation events thru it's inspector. And even select the event time by viewing animation.
    Or this method has some downsides?

  • @nullx2368
    @nullx2368 2 місяці тому

    This system is decent but it still feels meh, still one of the best solutions that we can do :( it really borthers me how unity didnt put some work in improving eventing during animations 😄 im curious how other engines deal with this, and if its better work flow

    • @git-amend
      @git-amend  2 місяці тому

      I'm not sure exactly what other engines do, but Unity's system of attaching their AnimationEvents as data within each AnimationClip does seem a bit short sighted. Unfortunately, it's probably also difficult for them to change now.

  • @pixeldustinteractive
    @pixeldustinteractive 2 місяці тому

    hmmm... what's the advantage of this over just going to the import of the animation and setting the event there?

    • @git-amend
      @git-amend  2 місяці тому +1

      For me, the main advantage of using this system over setting events directly in the animation import is that it allows separation of concerns by keeping event logic outside of the animation asset itself. For example, this allows you to reuse the same animation clip across multiple characters or states while customizing the events for each scenario, without duplicating or altering the original animation asset.

    • @pixeldustinteractive
      @pixeldustinteractive 2 місяці тому

      @@git-amend fair enough! I do like the fact that there are no magic strings to deal with if you set it up correctly

  • @RoxGame
    @RoxGame 2 місяці тому

    Nice job !

    • @git-amend
      @git-amend  2 місяці тому

      Thank you! Cheers!

    • @RoxGame
      @RoxGame 2 місяці тому

      @@git-amend Hi , could you check why my previous comment didn't appear !

    • @git-amend
      @git-amend  2 місяці тому +1

      No comments have been held for moderation, so I'm not sure...

    • @RoxGame
      @RoxGame 2 місяці тому

      @@git-amend That is weird ! Thank you for cheking