2D PATHFINDING - Enemy AI in Unity

Поделиться
HTML-код
  • Опубликовано: 1 июн 2019
  • Let's learn how to make 2D pathfinding using A* with and without code!
    ● Check out Skillshare! skl.sh/brackeys17
    ● A* Pathfinding Project: arongranberg.com/astar/
    ····················································································
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ► Join Discord: / discord
    ● Website: brackeys.com/
    ● Twitter: / brackeystweet
    ● Instagram: / brackeysteam
    ········································­­·······································­·­····
    ► All content by Brackeys is 100% free. We believe that education should be available for everyone.
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ········································­­·······································­·­····
    ♪ "ES_Dress Code_Black - oomiee" by Epidemic Sound

Комментарии • 1,4 тыс.

  • @lynxiberian7828
    @lynxiberian7828 3 года назад +2500

    Dude, you're literally making my final degree work. If i get the title, i'll get a very good contract in a big enterprise. My life will be very stable. I can't thank you enough for this
    Update: I got my title!
    Update 2: I got fired cause Coronavirus too hard for enterprise apparently
    Update 3: Just got a new job :D
    Update 4 because you guys keep asking haha: They had me doing boring simple stuff so I moved to another enterprise where I work on a way more interesting project ^^
    Update 5: Still in the same enterprise but different team and technology. Still not in videogame development but I got a stable life now so no big deal
    Note about the original comment: It wasn't a very good contract. It was decent at best, but young and innocent me didn't know any better lol

  • @taaamas7785
    @taaamas7785 4 года назад +246

    YES, i've been hoping you'd cover this at some point

  • @druidofpies
    @druidofpies 4 года назад +7

    Amazing that you released a video a week before I knew I needed it! Thanks my dude. I can always count on your simple, quality explanations for when I'm wandering aimlessly through the sketchy void that consists of 5 year old tutorials that provide complex and faulty solutions.

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

    As a teacher from QC I realy apreciate your philosophy and the way your videos are builds! Great job.

  • @billyrockstar
    @billyrockstar 4 года назад +15

    amazing content, I can't thank you enough for the effort put into this or the sharing of information. More people should make content like this. Technical expertise and well spoken. There isn't enough i can say about this.
    wonderful job, keep up the great work.

  • @Collcroc123
    @Collcroc123 4 года назад +11

    I'd love to see you do a video on the whole 3d animation thing, IDK how to tell when its idling, attacking, running, jumping, etc

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

    This is awesome! I scrapped a 2D Top Down RPG series because the pathfinding videos were becoming longer than the rest of the series! I didn't realize the free version of that asset was so powerful!

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

    I like how you show us a way we can obtain this without a lot of work, but also a way we can make this by ourselves

  • @arabkittysupreme
    @arabkittysupreme Год назад +26

    If you get an error about insecure connections not being allowed it is really easy to fix. Here's how you do it: in the top left click file, then build settings, then player settings, then other settings, scroll down to a setting called allow downloads over HTTP and make sure it is always allowed. it took me hours to figure this out lol

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

      Godsend, thanks for saving me time!! :D

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

      Life saver thanks

    • @billiboi122
      @billiboi122 7 месяцев назад +1

      The hero we needed

    • @ilyanuhi4923
      @ilyanuhi4923 6 месяцев назад

      thanks so much i was about to give up ^^

    • @AlfaCatOmega
      @AlfaCatOmega Месяц назад

      You saved me from wasting so many hours, thanks

  • @karficzfrizack2711
    @karficzfrizack2711 3 года назад +7

    Still come back to this vid every now and again. Miss your vids :(

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

    Thank you so much for this! I hope you'll keep going with this platformer pathfinding stuff and expand it further. There seems to be tutorials and assets for everything other than platformer pathfinding.

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

    This tutorial worked like a charm for me this time. Came back to it when i got a better understanding what the codes meant.

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

    it's awesome that he made the flying enemy so that you could also use it for top down.

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

    This came at such a right time. Could you please do some more on AI and some on testing??? That would be really helpful and thanks man, your videos are such an immense help...

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

    Yer videos are incredibly simple to follow and understand. Makes it super easy to Learn and actually Retain information. Thank you!

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

    Thanks Brackeys! I love the A* algorhtym and watch any video I see on it. I think I'll try this system since I don't have anything designated for 2D A* yet.

  • @pr0appleman415
    @pr0appleman415 4 года назад +11

    When i finished my bird enemy at my second enemy which i want to be on ground so i just added some gravity scale on the enemys rigid body and that actually worked.
    Except i want the enemy to jump whenever it needs to.

  • @craftgames4120
    @craftgames4120 4 года назад +7

    Brackeys is the BEST serious you CHANGED my life 😁😁😁

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

    I already knew how to do this but I watched the video anyways cause I always learn something new from your videos, no matter what.
    I wasn't wrong :D Thanks, Brackeys!!

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

    Great video!
    I was looking forward for this video for days..
    Thanks Brackeys!!!

  • @walterwhite42068
    @walterwhite42068 4 года назад +25

    Nice man. Just started my phone and u uploaded this vid.

  • @thefunnybuddy4138
    @thefunnybuddy4138 4 года назад +527

    "Keep Right"
    Turns Right
    Brackey your not allowed to drive anymore.

    • @Cookie204
      @Cookie204 4 года назад +56

      you're* not allowed to write anymore. XD

    • @VidimusWolf
      @VidimusWolf 4 года назад +16

      @@captainfordo1 error 418: I'm a teapot

    • @Aditya-wg3lp
      @Aditya-wg3lp 4 года назад +5

      Alex error 420: me me big boi

    • @jayocaine2946
      @jayocaine2946 3 года назад +10

      @@Cookie204 "Y"ou're not allowed to write anymore.

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

      @@jayocaine2946 You're not allowed to ''type" anymore.

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

    I've been waiting for you to do this video for a while. Great stuff👍👍

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

    I ALREADY MISS U GUYS, IVE SEEN THAT INTRO LIKE 3 TIMES AND IT ALWAYS MAKE ME LAUGH

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

    Awesome, please create more videos on 2D 👌🏻

  • @techtycho4752
    @techtycho4752 3 года назад +17

    Thanks, A* is awesome, I am using it to make my game in the Brackeys 2021.1 game jam!

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

      same

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

      Do you know why the enemies are only chasing the starting position of my player instead of following him around? (the enemies are not placed, they're spawned and both enemies and the player are prefabs

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

      @@sofikirkou idk

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

      @@sofikirkou I'm having the same problem.

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

    This is great, but would love if you could make a video showing more of you making the A* code! Its really easy to learn from you!

  • @10POWERGODDelGODSTEAM
    @10POWERGODDelGODSTEAM 2 года назад +2

    FINALLY, AFTER LIKE 10 TUTORIALS I FOUND ONE THAT WORKED. THANK YOU!

  • @whiteglint8191
    @whiteglint8191 4 года назад +221

    In today's Brackeys tutorial: "How to flip the bird"

  • @ho-jeonglee5860
    @ho-jeonglee5860 4 года назад +7

    Thanks for another great tutorial!
    A great start for a beginner.
    However, could you go over 2D grounded pathfinding with jumps and gaps, too?

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

      I'm finding that way too!

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

    I had a problem with a similar code where I couldn't figure out how to implement a function and this video helped. Cheers

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

    Really awesome A* implementation and video. Will use in my game. Thanks!

  • @ceejaylignes1971
    @ceejaylignes1971 4 года назад +5

    This is the tutorial I've been waiting for. Thank you brackeys!

  • @Hamstermoviespro
    @Hamstermoviespro 4 года назад +10

    Hey there Brackeys, Great video, I was definitely looking for something like this! I have a question however, when you write the code to flip the Sprite based on the direction it wants to travel, is there any reason why you use the local scale to flip the Sprite over the the SpriteRenderer.flipX property? Thanks.

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

    Awesome video as usual! I was expecting this topic some time ago. Thank you very much! :D

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

    I was just trying to do this man, thank you!

  • @christofferskog6859
    @christofferskog6859 3 года назад +3

    I wish you would have explained "nextWaypointDistance" a bit, since it can yield very different results based on the game you're making. I've found that increasing that value doesn't move my own character to the expected location. Decreasing it however makes you end up closer to the clicked location.

  • @FriedrichHabetlerMusic
    @FriedrichHabetlerMusic 3 года назад +96

    10:10 Brackeys you have "Flipped the Bird"

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

    Thanks man, I was unaware of A*. Seems like a great tool.

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

    Absolutely fantastic video. Thanks for giving me the details for this Engine-witchcraft. It's gonna make my game look super sophisticated. And now I can also add some originality. Awesome.

  • @danivalentine1280
    @danivalentine1280 4 года назад +34

    This is awesome and very helpful, but what about walking enemies that need to jump across platforms or onto higher surfaces to continue chasing the enemy?

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

      That's what I've been wondering for the past 4 and a half hours
      ha

    • @VidimusWolf
      @VidimusWolf 4 года назад +6

      Just program it yourself lol, use a little bit of intuition. For example, I've never done it, but I'd check for ledges one tile or so in front of me and if so, Jump(). If you want to make it sophisticated, check also for ledges that can actually be reached by the jump, so the enemy does not jump fruitlessly into a void.

    • @Shadowsphere1
      @Shadowsphere1 3 года назад +8

      Honestly, from playing and watching tons of 2D platformer games, there aren't actually that many that let enemies jump on platforms to follow players. Obviously, it makes them more viable as enemies, but it's not something I think many games do. Most of the time the enemies just fall under the platforms and the player gets to progress without opposition. In away, from a design standpoint, this works fine since it gives the player a sense of taking care of the enemies without having to brute force them.
      I personally think jumping over grounded obstacles is enough. A platform in the water, just have the enemies stop at the edge or fall into the water and die. Or I guess you could do what Terraria does and give enemies a set jump and if they make it, they make it, otherwise they fall.

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

      @@VidimusWolf Could get complex, but I suppose you could use vertical raycasts to check the corners of the enemy sprite to see if it's on a ledge, and if so, use horizontal raycasts to check a specific distance out that correlates to the limit it can jump. And if it is close enough, immediately jump before it fully goes off the ledge. Anyone using Rigidbodies might not have used raycasting too much, but anyone using raycasting as the basis for their controllers will probably do it that way or similarly (I'm new to raycasting, so I could also be speaking out of my ass)

    • @danivalentine1280
      @danivalentine1280 3 года назад +3

      @@Shadowsphere1 Great response, I like you viewpoint on this!

  • @BloodHoundPL
    @BloodHoundPL 4 года назад +7

    Hey, a really cool video you got there.
    Do you really need to use external A* when you can just lie your game down onto XZ plane and bake the NavMesh on a plane under the tilemap?

  • @stevedeniese5812
    @stevedeniese5812 7 месяцев назад

    Something worth noting, on path complete you want ot set your next waypoint to 1 not 0. This is especially important if you're updating animations based on speed and direction, and if you're not using forces to control your movement.
    i.e.
    private void OnPathComplete(Path p)
    {
    if (!p.error)
    {
    _path = p;
    _currentWaypoint = 1;
    }
    }

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

    Im folowing your tutorial series in wicht you teach how to make a platformer in 2d... I had problems with the pathfinding beacause it was old.... But here you are with a new video of this.... I love you!

  • @Chris-jl6vp
    @Chris-jl6vp 3 года назад +16

    What about a tutorial that does navigation for 2D ground-based enemies? I'd love to learn the process behind making entities jump and drop down through platforms to pursue the player.

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

      just don't set gravity to none, and add a box collider to the enemy

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

      Add colliders to the enemy and add a ridgid body 2d so it is affected by gravity.
      As for jumping, your probably are gonna have to do some code on how the enemy will jump when it hits a wall.

  • @jasonredway
    @jasonredway 4 года назад +320

    Any chance you could extend this tutorial for grounded characters that use the same physics as the player and need to jump to reach platforms?

    • @towercrowgames5115
      @towercrowgames5115 4 года назад +4

      Yes please.

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

      have you found a solution to having a grounded enemy yet?

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

      Did you ever figure this out ?

    • @ryanvanderlinden5431
      @ryanvanderlinden5431 4 года назад +56

      I finally managed it after 2 days of knocking my head against a wall. Always brings results.
      in the EnemyAI script where you rb.Addforce(force), (if you want to keep flyers), wrap this in an if statement with a bool (eg. canFly) and if the bool is false, only add force to the x axis.
      I was still having problems with ground units going over slopes. AddForce was just not working for it so I change mine to using rigidbody velocity which fixed it up well.
      Vector2 force = direction * speed * Time.deltaTime; // force that will move the enemy in the desired direction
      Vector2 velocity = rb.velocity;
      if (canFly)
      {
      // If a flyer, apply velocity in all directions
      // rb.AddForce(force); // the old method
      velocity = force;
      rb.velocity = velocity;
      }
      else
      {
      // If not a flyer, only apply velocity to the x axis
      velocity.x = force.x;
      rb.velocity = velocity;
      }

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

      Ryan Van Der Linden how would i make it jump over platforms to reach the player?

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

    A very great video, i've waited so much for something like this specially using Sunny land assets.

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

    this is exceptionally helpful, thank you!

  • @peterhernandez5377
    @peterhernandez5377 4 года назад +4

    How should we modify it for special enemies though? Like - what if an enemy needed to move in line of sight to fire a projectile? What if they had to manuever through an environment by jumping around or climbing ladders?

  • @urgian
    @urgian 4 года назад +7

    It would be interesting to see the AI of the ground character. With his reaction to obstacles and abysses.

    • @DarkGrisnak
      @DarkGrisnak 4 года назад +4

      Well, with the A*, he will just go under the target and try to fly 😅
      But it would be very interesting to look at how to make an AI able to jump over holes and (why not) go back to gain momentum and jump further !
      But I don't think we're going to see this on Brackeys because it's more about algorithm complexity than use of unity and its assets, unfortunately.

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

    Glad I watched the second half of this with the custom script. I spent hours trying to find a solution to why using all the default methods caused enemies to just overlap eachother and ignore colliders in general. Now my enemies crash in to each other the way I want it to.

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

    You are the bestttttt game dev youtuber 😍. You always brings with new and unique tutorial. I like the way you explain things.

  • @elpainto1
    @elpainto1 4 года назад +4

    AddForce already scales by fixed delta time ^^. In fact, if you do AddForce(direction.normalized * mass * drag * speed), you'll get a max velocity that is equal to the speed measured in units per second. Great video!!

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

      I took away deltaTime and now the sprite is zooming all over the screen.
      Pretty sure you need deltaTime in there.

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

      @@saydoer That's because FixedDeltaTime still returns 0.02 (by default) so if you you multiply by it, it'll change your end result. It's basically multiplying by FixedDeltaTime once automatically in addForce, and again when you do * Time.FixedDeltaTime. My guess is that you might be using large numbers like 500 for addForce which is a lot. Also if by chance you are doing addForce in Update instead of FixedUpdate then you might be adding that force more often than needed. Try the formula I mentioned above in Fixed Update with those values pulled from the rigidbody and you should get really consistent, predictable results. The catch is you'd have to either not use zero for mass and drag, or you'd have to add some small number in the code to keep it from applying a total force of zero

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

      @@elpainto1 I'm following the video in all respects, so yes these are going into FixedUpdate.
      I am adding a force of 500 for the speed, so that is probably what's causing it.
      Even after reading your description, I don't understand the difference (aside from the math) between your way of forming this vs. using force = direction * speed * Time.deltaTime.
      What, exactly, is gained by doing it your way?

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

      @@saydoer what you get when you bring in those other values is that the resulting speed is ( or is close to) a velocity in units per second that matches the speed variable you pass in, even if you change the mass and drag of the rigid body in the inspector.

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

      Maybe it's 3 yeas after, but I need to say your answer saved my project! Thanks!

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

    Brackey: *makes reached end of path variable*
    Also bracket: *never reads it again*

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

    That joke at the beginning ! Love it !

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

    Very approachable and enjoyable to watch!

  • @philippe6918
    @philippe6918 4 года назад +39

    HAHA intro XD, I thought there was a glitch with my computer lol

  • @aivancarlostuquero3782
    @aivancarlostuquero3782 4 года назад +120

    Start of the tutorial for hard coders 11:20

    • @brangtoggez6363
      @brangtoggez6363 3 года назад +3

      thank you

    • @kreyzgr5167
      @kreyzgr5167 3 года назад +29

      @@brangtoggez6363 well that actually wont work, you still need to set up A* and the seeker script which is before 11:20

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

    Thank you! you helping me so much and without you, I couldn't finish my first game

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

    How nice is this!, awesome dude! Love all of your content!, sweet and soft as baby towels! Cheers!! Keep going!

  • @abdelhaksallaoui5262
    @abdelhaksallaoui5262 4 года назад +12

    thank you for the Video! but why i can't find tha component named : pathFinding ???!!!! PLEASE HELP

  • @09SkyFrost
    @09SkyFrost 3 года назад +6

    Me sees description saying Line of code
    :D
    also me seeing its his merch store
    D:

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

    You are a great teacher. Keep up the good work

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

    Exactly the video I needed. Thanks

  • @miteric1145
    @miteric1145 4 года назад +4

    Perfect timing, just when I needed it, thank you for helping out so much you saved me so much time

  • @stepheninczech
    @stepheninczech 4 года назад +10

    Having some issues with this. I am using this code, but having my object move a set distance each update in the direction of the "direction" vector created using this code (as opposed to applying a force like the video does). But when the path invokes again and recalculates a new path to the target, there is a weird stutter that occurs. I think it is that the first new node that is generated when the path recalculates is actually slightly behind the object, causing it to turn back for a second, then continue moving towards the target. It creates a very disjointed-looking result. I haven't been able to solve this. Anyone have any ideas?
    Edit - Fixed it by making it so that when the currentWaypoint = 0, the vector current_waypoint is calculated using currentWaypoint +1 instead of currentWaypoint. Thereby skipping over to the next way point after a new path is calculated.

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

    these intros are just getting better and better

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

    Oh my god, how perfect isn't the timing?! Yesterday i needed this in my game and was searching around, but couldn't figure out how, so i ended up hardcoding a path with some random offsets since destination and spawn was the same position

  • @tic-tac-tocgames7310
    @tic-tac-tocgames7310 4 года назад +19

    How about a tutorial for dummies on how to use the unity 2019 new physics features to predict trajectories?

  • @drax_bs4974
    @drax_bs4974 4 года назад +11

    you should make a livestream focused on beginners, teaching them the basics of scripting in unity and etc!

    • @las9674
      @las9674 4 года назад +13

      Or you could watch his series “How to make a game in unity”

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

    I think the biggest thing I learned from this was InvokeRepeat, never knew that was a thing, oh boy will things become easier from now on!

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

    You’re doing the lords work. Keep it up!

  • @robertpiwowarek5354
    @robertpiwowarek5354 4 года назад +5

    Hey @Brackeys I have encountered a problem where the Scan button doesn't create unwalkable spaces around my obstacles (despite them having a similar settings to yours, did you ever happen to have similar problems? Do you have any suggestions? (tried potentially checking Z on my obstacles related to A* and setting them at the same level, as different ones didn't work, tried thicc height testing, my objects do have box colliders) And I sort of run out of ideas here as to what could be wrong.

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

    Great video! Could you make a plants vs zombies replica? Or a turnbased tankshoot game like tankstars with the destructible environment- replica :D? Thanks

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

    Man! You save my Academic Project!!!! Thank You very Much!!!!!

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

    Summertime; Time to binge all you videos

  • @mehdibadaoui1658
    @mehdibadaoui1658 3 года назад +7

    your videos hit different now that i know you won't make anymore

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

    22:06 "That should look even better"
    *bird starts flipping super fast for no reason at all, buggy as heck*
    "Yup, I definitely like that quite a bit"

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

      Yeah, I'm having issues with this as well. Have you found a solution?

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

    Thank you! Very helpful tutorial!

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

    Amazing job, congratulations for the channel☺

  • @TheZildjian11
    @TheZildjian11 4 года назад +11

    If you did a scan and it didn't register any obstacles, it's because you need to add a Tilemap Collider 2D to your tiles!

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

      Top ! Thank you for the information its all I was looking for.

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

      @@TheOneTaboo yall run this bitch! thanks for the info

    • @tyedwards6356
      @tyedwards6356 4 месяца назад

      you sexy gorgeous being xxxxxxxxx

  • @AndrzejGieraltCreative
    @AndrzejGieraltCreative 4 года назад +12

    What if you want the enemy to use gravity and jump after the player? I'm trying to allow it to use gravity based on the enemy's rigidbody but, it's falling slowly for some reason. When I disable the pathfinding script, it falls normally. When I use the pathfinding gravity, it falls through platforms even though I set the layermask in the pathfinding script to include the platform layer.

    • @praised_goodness
      @praised_goodness 4 месяца назад +1

      you should try to make the enemy follow after the path only on the x axis and only jump if the next waypoint is higher than a certain threshold and the enemy is grounded

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

    As always, awesome video!

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

    THANK YOU SO MUCH! Tomorrow is my final project and my enemy did not move no matter what I did, thank you, not only now it moves, it also was easier to do!

  • @DarkGrisnak
    @DarkGrisnak 4 года назад +5

    Super helpful, thanks ! ;)
    However I think there is a little mistake here. Your condition to increment currentWaypoint makes the AI not going to the end of the path. the "newtWaypointDistance" acts like the endReachedDistance. Be careful for those who'd like to use it, that could surprise you :)
    (It was a problem for me as I needed precise movements)

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

      how did you fixed that? I'm trying for 2 hours, please help me lol

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

      @@bwulf any fixes??

  • @Robertganca
    @Robertganca 4 года назад +109

    Brackeys: “Alright, lets make some enmities.”
    Me: 😂😂😂

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

      that was enimeis you deaf!!

    • @avo143
      @avo143 4 года назад +5

      @Levi Ackerman I don’t know if the way you spelled “enemies” was spelled wrong on purpose or not...

  • @user-vv2vz2tl1n
    @user-vv2vz2tl1n 4 года назад

    You are the best bro. Thanks for helping me figure out A *

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

    This will be very helpful, thanks!

  • @Mekhel
    @Mekhel 4 года назад +30

    1:22 imagine saying that out loud in public

  • @PLSchannel
    @PLSchannel 4 года назад +69

    My new dream: Take a photo with Brackeys on my graduation day.

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

    Ahhh all these tutorials are soo good.

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

    I already miss these guys

  • @nullified__
    @nullified__ 4 года назад +18

    Brackeys Could You Make A Mobile Game ? (And Make It A series?)

    • @gregoryfenn1462
      @gregoryfenn1462 4 года назад +7

      Apart from the input, which you can control with the Input class and define in a cross-platform manner, it's just the same as a 2D (usuallly 2D) high-performance low-graphics game.

  • @BattleAngelSound
    @BattleAngelSound 4 года назад +5

    Great video. I would love to see these tutorials taking into consideration player death and respawn because sometimes when everything is alright the game is freaking out at the moment player GameObject is destroyed (or enemy may not follow spawned player prefab anymore).
    I had to edit AIDestinationSetter.cs so the enemy is searching for player again after its respawned (WaitForSeconds is because my player spawn after 2 seconds after being destroyed and it helps to avoid NullException error, without the delay maybe searching for tag may be done directly in Update function).
    void Update ()
    {
    if (target != null && ai != null) ai.destination = target.position;
    StartCoroutine("FindPlayer");
    }
    IEnumerator FindPlayer()
    {
    if (target == null)
    {
    yield return new WaitForSeconds(2f);
    target = GameObject.FindGameObjectWithTag("Player").transform;
    }
    }
    It's probably totally messed and there's probably more efficient way to do it but I'm just a sound designer messing around with Unity ;)

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

    I should learn by now that when in doubt, search for Brackeys. 2D pathfinding for a Metroidvania type game has been rattling my brain for a bit. 2D sidescroller pathfinding in general rattles my brain. Thanks for supporting the Unity community!

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

    Damn i always wented to learn pathfinding, thanks man!

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

    You should have seen the smile on my face when he said: no coding!

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

      If you don't like coding, you should probably switch to something like unreal engine lmao

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

      @@sneggulf Well I do like coding, and I prefer Unity for the community, but I just don’t like writing loads of C# scripts

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

    Great video! Just a question, shouldnt you use Time.fixedDeltatime or whatever its called instead of Time.deltatime? Since you are in the FixedUpdate()?

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

      Oh - I just asked the same question. Based on Unity Documentation, the answer is YES.

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

      what's the difference ?

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

    Great tutorial. It's possible to do path finding, using this method, for an enemy that can't fly but can climb or move on ladders?

  • @FC-BS
    @FC-BS Год назад +1

    Thanks for this video, it helped me with my task at school