ADVANCED AI IN UNITY (Made EASY) - STATE MACHINE BEHAVIORS

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • In this AI unity / C# tutorial we will take a look at how to use the animator to get your enemy characters or NPCS switch behaviors, movement patterns, play sounds and more !
    ------------------------------------------------------------------------------------------------------
    LINK to the ANIMATOR TUTORIAL : • HOW TO MAKE ANIMATION ...
    LINK to the ENTIRE AI SERIES : • AI TUTORIALS WITH UNIT...
    DOWNLOAD the PROJECT : github.com/Bla...
    ------------------------------------------------------------------------------------------------------
    SUPPORT ME : / blackthornprod
    ------------------------------------------------------------------------------------------------------
    FOLLOW ME on TWITTER : / noacalice
    JOIN the BTP DISCORD SERVER : / discord

Komentáře • 209

  • @beri4138
    @beri4138 Před 4 lety +42

    Damn. You can make an entire game inside of the animator. That's crazy.

  • @reubenlouwerse4251
    @reubenlouwerse4251 Před 6 lety +40

    It feels like whenever I need to know how to do something for my game, you just happen to cover it! Great video!

  • @wVAjaxVw
    @wVAjaxVw Před 6 lety +183

    How did I not know about behaviors in the animator?

  • @DawnosaurDev
    @DawnosaurDev Před 6 lety +67

    Yes
    Yes
    Yes
    So much easier than using the official unity video (Finite state machines probably outdated)
    Most useful video yet!!!

    • @brandonfleming7118
      @brandonfleming7118 Před 5 lety +1

      everything on the unity site is outdated some as old as version 2

  • @shanestevens516
    @shanestevens516 Před 6 lety +2

    This video was so helpful but not in the way you might think. I know how to make advanced AI using a finite state machine, But I've completely overlooked the StateMachineBehavior with the Animator to play particle effects or other behaviors when entering and existing animations! THank you!

  • @javiermahana3475
    @javiermahana3475 Před 5 lety +1

    WOOOOW...
    I tried myself to make a state machine countless times and in the animator is one just waiting for us!!!
    Noa you are great and you save me a lot of time :DDDDD

  • @tejaschalke1778
    @tejaschalke1778 Před 6 lety +4

    I expected part 2 of ranged attack tutorial first, but this is a great Video. Loved it !!!

    • @Blackthornprod
      @Blackthornprod  Před 6 lety +1

      Thanks :) ! I'm really happy you liked this video, and of course ranged combat Part 2 will come out soon enough :) !

  • @MuhammadAdnan-lq6gc
    @MuhammadAdnan-lq6gc Před 6 lety +2

    Awesome and unique tutorial. This tutorial really opened my eyes about the possibilities Unity is offering to develop quality games. Great thanks for these kind of tutorials.

  • @silencer3kmg
    @silencer3kmg Před 4 lety

    Of all the people out there making tutorials for UNITY your videos are definitely the only ones that say "go watch another video to learn this part".
    Most people show how to do something from start to finish. Not show the middle and then recommend in their video to go watch two other videos. click bait is click bait

  • @bunggo9914
    @bunggo9914 Před 6 lety +123

    so we can add scripts to an animation! wow....

    • @MrPoporucha
      @MrPoporucha Před 5 lety +8

      Most enemies in the game Rainworld uses animator behaviours for AI

    • @danbobjim123
      @danbobjim123 Před 5 lety +4

      @@MrPoporucha cool!

    • @magnusm4
      @magnusm4 Před 4 lety +13

      What's also awesome is you can add scripts to the animation itself.
      You open the animation window, drag in the animation and then you can add a script anywhere in the time of the animation.
      So you can start a gun particle or hammer swing at any point in the animation.
      Like if your enemy has a delayed jump, then instead of coding in a delayed particle, you instead just make the animation call the function in the script at the point he jumps.
      Easy peasy lemon squeezy

    • @monkeyrobotsinc.9875
      @monkeyrobotsinc.9875 Před 3 lety

      @@magnusm4 nioce

  • @michaeloconnell145
    @michaeloconnell145 Před 5 lety

    You have blown my mind, the animator behaviors are brilliant!

  • @Vengard1000
    @Vengard1000 Před 6 lety +5

    WHY CAN'T I THUMBS UP MORE THAN ONCE!!! Haha, great video. Very informative, simple, and useful information.

  • @ludicrouS_406
    @ludicrouS_406 Před 4 lety +3

    Blackthornprod: some vicious warcry
    No one:
    Enemy: yAAAA

  • @SSMLivingPictures
    @SSMLivingPictures Před 4 lety

    With full sincerity, thank you so much for this video and doing what you do. This answered so many riddles I had about hurdles with my own game and propelled my knowlegde / progress forward so much I cant even tell you. I swear I was just waiting to find this video. Cant thank you enough.

  • @dr.mailman
    @dr.mailman Před 4 lety

    Wow I never knew how to utilize the behavior scripts. This is drastically going to change the way I make CCs and AI

  • @1ht1baron
    @1ht1baron Před 6 lety +18

    Could you make a tutoriel about smart enemy ai (can jump, climb,...) on side scroller 2D?

  • @buraqalaeli6619
    @buraqalaeli6619 Před 2 lety

    Amazing and simple tutorial, this will boost my production really well!!

  • @Justeeee115
    @Justeeee115 Před 3 měsíci

    Awesome this just give alot of ideas on how to make my ai with ease

  • @skyacaniadev2229
    @skyacaniadev2229 Před 5 lety +8

    I'm using animation events all the time without knowing that I can attach script to animator states...

  • @TheRealMobiius
    @TheRealMobiius Před 4 lety

    Completely revolutionized the way I'll do AI from now on!! :)

  • @MSarhan
    @MSarhan Před 6 lety +3

    Great tutorial but please if you can do a tutorial on tilemaps because I'm sure that it will be great to learn that from you

  • @TheArtist808
    @TheArtist808 Před 4 lety

    Easily the best tutorial of this type on CZcams

  • @luciacover9909
    @luciacover9909 Před 6 lety +2

    Hey Noa! Great video and your Ludum Dare game looked so fun! I hope you were able to get your game on the leaderboard! Is this what our boss battle tutorial is? If so it’s made very well! Have a good morning, day, and evening!

    • @Blackthornprod
      @Blackthornprod  Před 6 lety +1

      Thanks Ben :) ! No this wasn't really my boss tutorial, that will come out some time soon ;) !! And I'm really glad you liked my LD game ! The feedback I received was awesome, helpful and so motivating (3rd most rated game of LD so far :D) !

    • @luciacover9909
      @luciacover9909 Před 6 lety

      Blackthornprod well I hope it stays in that place or goes up

  • @TrueValience
    @TrueValience Před 6 lety

    once again another awesome tutorial from my fav unity channel

  • @eddgrs9193
    @eddgrs9193 Před 5 lety +1

    best State Machine explanation video ever.

  • @daveejons
    @daveejons Před 6 lety +9

    Alright next tutorial has to cover ai moving around obstacles

  • @mirela9974
    @mirela9974 Před 6 lety +4

    Awesome tutorial as always!

  • @DrRoncin
    @DrRoncin Před 4 lety +2

    Thanks for the great tutorial! Loved the simplicity of this technique. Without animations, I encountered a 0.5s delay between exiting state A and entering state B. -> The "Has Exit Time" has to be turned off for fast transitions.

  • @Norbingel
    @Norbingel Před 4 lety +32

    Alright, where's the promised part 2? :D

    • @TheUnscriptedMind
      @TheUnscriptedMind Před 4 lety +1

      unable to use the search function???? czcams.com/video/bY4Hr2x05p8/video.html

    • @Norbingel
      @Norbingel Před 4 lety +5

      @@TheUnscriptedMind thanks but that link is to a 2D ranged combat system

    • @TheUnscriptedMind
      @TheUnscriptedMind Před 4 lety +1

      @@Norbingel and he said what? Part 2 "Ranged Combat Tutorial" .... 7:45

    • @Norbingel
      @Norbingel Před 4 lety +2

      @@TheUnscriptedMind I was actually referring to 7:30 where he said "it is very likely that I made a part 2 State Machine Behavior Tutorial in the near future" right before he says the part about making a Ranged Combat Tutorial.

    • @TheUnscriptedMind
      @TheUnscriptedMind Před 4 lety +1

      @@Norbingel czcams.com/video/cXefXSD2SM0/video.html maybe this? that video was 1 week later and has state machine behaviours...

  • @solid-parker237
    @solid-parker237 Před měsícem

    "Ahhhh, help! The enemy is FARTING towards me"

  • @tyelork
    @tyelork Před 6 lety +3

    Finite State Machines are also good for controlling the state of the game, i.e. MainMenu, Running, Paused, Game Over, etc.
    I also ended up writing my own generic FSM for my LD42 Compo entry, but only used it for the game state. If I make enemies it's generic enough to use for enemies behaviors.
    I've never used the animation system to control states though, that's a neat way of going about it.

  • @deraminator945
    @deraminator945 Před 2 lety

    This is how a state machine works???? This looks very understandable

  • @snipy27
    @snipy27 Před 6 lety +1

    Never used state machines before, but it looks really nice to use, gonna try it out for sure :)

  • @cinemacat4108
    @cinemacat4108 Před 3 lety

    I know that my comment is late but if you want to check if the player is near the enemie you can
    Physics2D.OverLapCircle(enemie.position, raidus, "the layer of the player");

  • @AzaiKang
    @AzaiKang Před 5 lety

    Damn, this is a more easy to understand than my current enemy AI script. Thanks!

  • @no_0nehere_875
    @no_0nehere_875 Před 3 lety

    Yup you opened my Eyes. Starting Unity now....

  • @Lizard_geek
    @Lizard_geek Před 5 lety

    I have made game in Blender Game Engine in the past and I gotta say im glad ive started learning unity.

    • @leetness13
      @leetness13 Před 5 lety +1

      next step is the Unreal Engine, 100 times more powerful than Unity :)

    • @tijon1350
      @tijon1350 Před 3 lety

      @@leetness13what you're saying is bullshit, unity and unreal engine are both same powerful

  • @dharmeshkumar2763
    @dharmeshkumar2763 Před 6 lety +1

    today i learnt a new thing. i have never seen this type of tutorial before......thankssss.......
    i want to confirm one thing that does 'animator.transform.position' indicates enemy position in this tutorial?
    now i am waiting for part-2 of this tutorial.
    great work.....

    • @Michael-The-Composer
      @Michael-The-Composer Před 6 lety +1

      Yes, animator.transform.position does indicate the enemy's position because we are setting it to move towards the player.

    • @user-bo5vr1ib6i
      @user-bo5vr1ib6i Před 5 lety +1

      "animator" is a property in the StateMachineBehaviour class of which the script is deriving from, which has the type Animator and holds a reference to the Animator component on the GameObject, in which holds the property "transform" of type Transform, which holds the reference to the GameObject's Transform component, in which has the property "position" of type Vector3, which holds the position of the GameObject.
      And since the Animator he was making a behavior script for was sitting on the enemy, yes, it is referring to the enemy's position.

    • @dharmeshkumar2763
      @dharmeshkumar2763 Před 5 lety

      @@user-bo5vr1ib6i thanks

  • @simoncodrington
    @simoncodrington Před 6 lety

    Cheers for the videos mate :) You always have really top notch stuff.

  • @Steven_Something20
    @Steven_Something20 Před 6 lety

    AI with pathfinding for 2D would be great as well. Something like A*, but with your breakdowns of the mechanics would be very helpful.

  • @abidounesaad3780
    @abidounesaad3780 Před 6 lety +10

    Hey Noa thanks for the video, I absolutely love your content, can you please recommend some learning materials for Unity??

    • @Blackthornprod
      @Blackthornprod  Před 6 lety +5

      Hey :) !! Best learning material available is on the actual Unity website (Space Shooter and Top down Shooter series) and on CZcams (on my channel, Brackeys and Sebastian Lague ;D) ! You can also check out the UDEMY website and search for Unity courses, there's a couple great tutorial series out there as well (payed though)!

    • @abidounesaad3780
      @abidounesaad3780 Před 6 lety +1

      Thanks for replying, keep up the great work!

    • @rashidfarhan6223
      @rashidfarhan6223 Před 6 lety +1

      Sebastian Lague tutorials are really good if you're from a programming background, you'll find his videos interesting.

  • @zachgeyer8090
    @zachgeyer8090 Před 4 lety

    Thanks for the tutorial! This is really useful for my current project!

  • @TheFritoNation
    @TheFritoNation Před 3 lety +3

    Great video! I remember watching this when I was new to game development and now that I'm more experienced I was wondering when you would want to use this rather than regular code?

  • @upstart_art6558
    @upstart_art6558 Před 3 lety

    Dude, you deserve lot of subs after brakeys leave you are been my brakeys now

  • @dragon121978
    @dragon121978 Před měsícem

    Great video, can you explain how to do the same thing but rather than hitting a button to change states, the npc changes states with either line of sight or within a range of the npc

  • @darkbibni
    @darkbibni Před 6 lety

    We have used that same system to create some Boss AI in our student game ^^
    A Better AI option is behaviour tree if you need very complexe AI !

  • @CybeargPlays
    @CybeargPlays Před 5 lety +2

    Are there any downsides to using the animator's state machine as the AI state machine? And on the flip side, are there any upsides to creating a parallel, code-based state machine for the AI and keep the animator state machine to visuals/animations only?

    • @CustardCream33
      @CustardCream33 Před 4 lety

      Really want the answer to this! Stumbled across this video because i'm lost but i'm not sure if it's good practice to use it without any animations..

  • @tunvas
    @tunvas Před 2 lety

    When do you use State Machine Behaviours and when do you create your own pure C# State?

  • @xekser-132
    @xekser-132 Před 6 lety +2

    Finally, waiting so long!

  • @LittleGameDev
    @LittleGameDev Před 6 lety +2

    Hey Noa, i need a bit of help.
    do you know where I can find some tutorials for Unity on making a cooking tycoon?
    I been trying to find a cooking tutorial where the player has to cook, then leave there cooking station to sever customers. Kind of like Chocolate tycoon but instead of the serving the customers at the counter you serve them at a table.
    If you don't know any tutorials on this could you please post a video explaining how you would tackle the challenge.

  • @bladefier1954
    @bladefier1954 Před 4 lety

    God... That was easy... Thank you so much Noa

  • @durrium
    @durrium Před 3 lety

    Very cool! One question: is this state machine animator a separate animator from the enemys walking animator?

  • @kdawgfsho04
    @kdawgfsho04 Před 3 lety

    instead of key down to get him to start following from idle i just want him to start i dont want to press keys.. how would i do this?

  • @Gooseguy1000-1
    @Gooseguy1000-1 Před 2 lety

    This is interesting, but wouldn’t it just be easier to give them multiple scripts and use setActive when you want them active, and the opposite when you don’t want them active?

  • @_Garm_
    @_Garm_ Před 6 lety

    cool use of the built in state machine :D

  • @MV-dh6ve
    @MV-dh6ve Před 4 lety

    Love your tutorials! Thanks

  • @koks49045
    @koks49045 Před 5 lety

    Why you cant drag and drop gameobjects from your SCENE onto public GameObject in your scripts that were added to particular animation? Normally thats obvious that it works, in normal scripts it always works, but if scripts is added thorough this add behavior options, this just doesn't work...

  • @wignermatos6616
    @wignermatos6616 Před 6 lety +2

    Thanks for the video !

  • @urzytkownikYT
    @urzytkownikYT Před 5 lety +12

    Is that really a good approach to controll AI through anim states? shouldnt some ai manager itelf controll animator?

    • @caxopog
      @caxopog Před 4 lety +1

      Yea, a very interesting question. Cause... it looks strange when AI is controlled by ANIMATOR, not vice versa

    • @diliupg
      @diliupg Před 4 lety

      @@caxopog stranger things ... ;-)

    • @tonywoods1226
      @tonywoods1226 Před 4 lety

      It's actually alright. It's good for visualization

    • @arcclite1144
      @arcclite1144 Před 4 lety +3

      @@tonywoods1226 I think the point is for any project of decent size, you probably want to isolate your "animation layer" from your "AI state machine layer" better than this. It's a good visual tool, but it's not how you probably "should" code it, separate from Unity's helpers. It depends a bit on how much of your game BL code you want to live "in" Unity, vs just being C#.
      EDIT: since this has a few updoots now, and as someone doing exactly this, I'd say (in general) aim to have your new state's "onBegin" callback trigger your animation changes. That's worked really well for me so far. "Player hit attack button -> change to attack state -> animate the attack", with various BL/validation goo.

    • @aldigangster123
      @aldigangster123 Před 4 lety

      wondering myself. There is a Unity talk with the Fire Watch developer talking on state machines / animator. And at the end he is warning on using the animator as a state machine, like shown here as well. He meant it can get easily very complex and hard to debug, if everything lives in the animator. IMO, It's definitely no issue with a simple project like shown here, but rarely any tutorial shows an implementation for an actual realistic project, with more than just two objects following each other. I'm tempted on using it, but I think down the road, I will be making my life easier when the Finite-State-Machine is controlling everything incl. the animator, and not the other way around. Jason Weismann is showing good beginner friendly implementation of FSM, if anyone is interested.

  • @magnusm4
    @magnusm4 Před 4 lety

    Been stuck on movement controls for years.
    But this state code has gotten me so excited I immediately got to Blender and started modeling to then rig and animate it to use this.
    Is it possible to have already declared variables? So for example you don't have to declare a movement variable to be equals to the player's velocity every time you start walking . Especially if you have multiple variables and stats affecting movement.
    I wonder if these state scripts can get other scripts's variables.
    For example I still have a movement script on the player which handles falling, input, physics, drag and such so that there's universal effects on the player regardless of animation state.
    Also accessing some variables of the player such as speed, strength force etc.
    Wouldn't want a Tomb Raider where jumping is hard coded so you can glitch and run in the air. Still have no idea why anyone ever thought that was a good idea.

  • @thekingsfool8879
    @thekingsfool8879 Před 6 lety

    Another awesome video. Thank god for BTP :-)

  • @eren_guneri
    @eren_guneri Před 2 lety

    With the MoveTowards the enemy can't collide with any colliders. Is there a way to prevent this?

  • @psycho7083
    @psycho7083 Před 6 lety +4

    The "private PatrolSpots patrol;" is highlighted with red... what i need to do? I need to create a script called PatrolSpots? If i need to do this what needs to be writhed inside this script?pls help;)))

    • @namcon555
      @namcon555 Před 6 lety

      Late reply but you’re going to need another script called ‘PatrolSpots’. I’m sure this is all explained in his AI series, but it looks like the PatrolSpots class will probably generate an array of random coordinates Called patrolPoints. Basically you’re gonna need to watch his other series on AI.

    • @wyzebeatz3742
      @wyzebeatz3742 Před 5 lety

      I was wondering about this too. I looked at the project files and PatrolSpots and the only thing inside of it is an array of transforms called patrol points. Not working for me. But here's the link to the script github.com/BlackthornProd/State-Machine-Behavior-Tutorial/blob/master/State%20Machine%20Project%20Files/Assets/Scripts/PatrolSpots.cs

  • @misterprop9089
    @misterprop9089 Před 6 lety +1

    You are the best youtuber for the unity tutorial

  • @shinkouhai919
    @shinkouhai919 Před 4 měsíci

    You just saved me from a spaghetti code...

  • @fatemermg7490
    @fatemermg7490 Před 4 lety

    it definitely opened my eyes!!

  • @sumanth664
    @sumanth664 Před 5 lety

    Hey Noa, I've come across your channel recently and you've pretty great content. Can you make a video specifically for game audio as in how to select audio or the theme to the game and its implementation.

  • @AndrzejGieraltCreative

    Awesome! Could you do a tutorial on how to integrate things like opening doors into AI pathfinding?

    • @tijon1350
      @tijon1350 Před 3 lety

      make a sight collision box and if there is a door close in the sight collision box, open it. (the script is really simple, nothing special.)

    • @AndrzejGieraltCreative
      @AndrzejGieraltCreative Před 3 lety

      @@tijon1350 hmmmm is it though? What if he's in a tight space and the collision box hits 2 doors? I've been having a lot of trouble with this tbh, I was using raycast earlier but haven't touched the idea in a while.

  • @ma08serrano
    @ma08serrano Před 5 lety

    cool. this exactly what i am looking for. thx

  • @disgrandpa247
    @disgrandpa247 Před rokem

    highly unlikely this gets a reply now, but no matter what i try i keep getting null reference exception errors for the patrol behaviour when trying to make it work from the other video, anyone able to help?

  • @richnaisanze
    @richnaisanze Před 5 lety

    part 2 pleasee! nice vid keep it up !!

  • @unityhelp6139
    @unityhelp6139 Před 4 lety

    Very useful tutorial.

  • @VBox_tuhin
    @VBox_tuhin Před 3 lety

    awesome video dude .. ❣❤

  • @voluntaryneet9813
    @voluntaryneet9813 Před 3 lety

    How would I flip the sprite in the direction it is moving?

  • @someoneelsecrystaloffical458

    Do You Know How To Make A More Advanced AI
    So Like Level
    3 AI

  • @MAMFMAHMOUD
    @MAMFMAHMOUD Před 6 lety +1

    hi noa, can you make a tutorial about how you make (walking/running/idle/jump) animation ? cause i am having a hard time with it.

    • @dc5285
      @dc5285 Před 5 lety

      Il send you a link later if i forget remind me

    • @sirtroll4546
      @sirtroll4546 Před 5 lety

      @@dc5285 i think he forgot to remind you

  • @FadilSyhptra
    @FadilSyhptra Před 2 lety +1

    thank you bro

  • @clintonyong1541
    @clintonyong1541 Před 6 lety

    Hi there blackthorn. Love you video very much! Can you do a tutorial on how to make a 2D character slide for dodging obstacles? Thank you so much :)

  • @sleepingknight3832
    @sleepingknight3832 Před 6 lety

    Nice video!!, can you make a full RPG tutorial?

  • @valdytech2002
    @valdytech2002 Před 6 lety +1

    really great job !!

  • @felipexg4032
    @felipexg4032 Před 5 lety

    All the spaggetti code to the trash. Must remake the AI again. I love you man....
    I'm crying... kinda happy?

  • @MeowMeow-ev8tv
    @MeowMeow-ev8tv Před 3 lety

    Question, is this better than coding state machines with enum and switch cases?

  • @Qirbb
    @Qirbb Před 5 lety +1

    i have a problem with the patrolspots thinggy
    andd pls correct my input
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PatrolBehaviour : StateMachineBehaviour
    {

    private PatrolSpots patrol;
    public float speed;
    private int randomSpot;
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateinfo, int layerIndex)
    {
    Patrol = GameObject.FindGameObjectWithTag("PatrolSpots").GetComponent();
    randomSpot = Random.Range(0, Patrol.patrolPoints.Length);
    }
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    if (Vector2.Distance(animator.transform.position, Patrol.patrolPoints[randomSpot].position) > 0.2f)
    {
    animator.transform.position = Vector2.MoveTowards(animator.transform.position, Patrol.patrolPoints[randomSpot].position, speed * Time.deltaTime);
    }
    else
    {
    randomSpot = Random.Range(0, Patrol.patrolPoints.Length);
    }
    if (Input.GetKeyDown(KeyCode.Space))
    {
    animator.SetBool("isPatrolling", false);
    }
    if (Input.GetKeyDown(KeyCode.P))
    {
    animator.SetBool("isPatrolling", true);
    }
    }
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    }
    }

  • @russellzeeryp9067
    @russellzeeryp9067 Před 4 lety

    Does this no longer work? I'm having issues with the following: transform. It says, "GameObject[] does not contain a definition for 'transform' and no accessible extention method 'transform' accespting a first argument of type 'GameObject[]' could not be found."
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    playerPosition = GameObject.FindGameObjectsWithTag("Player").transform;
    }

    • @BRINK2011THEGAME
      @BRINK2011THEGAME Před 4 lety +1

      Russell Zeeryp Did you named “playerPosition” on your Transform field? Did the player gameobject have the tag assigned correctly with “Player”?

  • @fog_cast
    @fog_cast Před rokem

    I just learned how to make state machines, I've been doing it by hand all in code and just learned that this exists... ugh

  • @PxlDev
    @PxlDev Před 5 lety

    The type or namespace PatrolSpots could not be found...

  • @arcenciel99
    @arcenciel99 Před 4 lety

    just wondering, what's the difference between if we add the same scripts to the enemy and to the animation?

  • @faiz7180
    @faiz7180 Před 4 lety

    If i want to make the enemy from follow to idle it should be vice versa right? Which mean that the enemy will chase me and then when i press button it will stop. I'm fairly new to unity, so i'm so confused rn.

  • @asdf7053-n9w
    @asdf7053-n9w Před 5 lety

    Great video. Thanks a lot :)

  • @AbdulWahab-ev2ct
    @AbdulWahab-ev2ct Před 6 lety

    amazing good work. ! Keep doi'n it.
    can u please do a video which covers the dimensions, optimization and quality of art in pixels (should sprites be in 1024x1024 , 512x512 etc or ) for better and maximum result in unity without having any performance issues
    Kind Regards
    abdul

  • @magnusm4
    @magnusm4 Před 4 lety

    Is it possible to have a main script that the animation scripts either inherit or gets their info from?
    For example I have a player movement script with a Character Controller and a mainMove Vector3.
    I want the animation for jumping to make mainMove.y = jumpHeight;
    So basically, instead of coding all the movement stuff in a movement script I spread each action to the animations and the main movement script instead handle input and setting variables as well as holding them.
    So the animation scripts don't instance mainMove but reference it so they affect the main movement Vector3

  • @carlosnava1653
    @carlosnava1653 Před 5 lety

    Is there a way to change npc animations as regards left or right direction? I've tried using blend trees, but i can't make it work.

  • @julianorocha2280
    @julianorocha2280 Před 6 lety +1

    My eyes are now open. And my mind blowed up

  • @gobblestheturkey1413
    @gobblestheturkey1413 Před 3 lety

    Thats gunna be an insta-subscribe from me dawg.

  • @beelancah340
    @beelancah340 Před 6 lety +1

    Cool tutorial

  • @lorenzodezi2349
    @lorenzodezi2349 Před 4 lety

    I was wondering: isn't it costly to initialize the fields of the behaviour every time OnStateEnter is called? Is there a better way to initialize things once, like patrolSpots?

    • @joll98
      @joll98 Před 4 lety

      yeah especially with using findGameobjectwithTag, better to cache it. something simple I can think right now is put a bool check condition to make sure the patrolSpots is found only once

  • @Skyvastern
    @Skyvastern Před 4 lety +1

    What the freak, didn't even know there was a thing like this that existed. And now when I think of it, yes there was this add behaviour button on animation states, and to my surprise I never bothered to care about what it actually does 😅

  • @williamstrnad4243
    @williamstrnad4243 Před 6 lety +2

    Best unity youtuber!

  • @dennisgonzales9521
    @dennisgonzales9521 Před 5 lety

    I used "Rigidbody2D" here and it doesn't work as I expected, the character has so much speed in him and he flew off the screen.
    When I replaced it just like your code "animator.transform.position" patrolling works, but this is not what I want cause he has no rigidbody.
    Any help?
    thanks bro

  • @emil.........
    @emil......... Před 5 lety

    What is the best way to combine this with an actual animation controller with normal animations?