Enemy Gather Around Player - Top Down Unity 2D

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'll show you how to fix enemy pathing make them stop lining up like this and stacking and instead we'll gather around your player like this in our previous video we got an enemy chasing our player I'll link this below right now our enemy goes on top of our player so to stop this from happening We'll add some colliders first click on our player and add a box collider 2D then click on our enemy and add a capsule collider 2D edit this collider and give it a bit of breathing room so they're not touching otherwise it looks a bit weird when we press play you can see he's just barely touching him you can see as our enemy reaches our player it pushes them so to fix this what you can do click on our player object and in its rigid body 2D set the mask to something high like 1000 this is just a quick fix you can see now he doesn't push him now I'm going to make this enemy a prefab by dragging it over into my assets then I can drag lots of enemies into our game scene gonna make this a bit smaller just set the scale to 0.5 and when we press play you can see our enemies all Stack Up kind of in a line and it looks a bit weird it's not like they're actually trying to get to our player so to fix this what we can do is add a physics material to our enemies rigid body 2D to create this in your assets right click and go create 2D physics material 2D and I'm going to name this frictionless enemy and here I'm going to set the friction to zero and then the bounciness to be 0.01 now if we click back on our enemy prefab scroll down and drag our frictionless enemy material into the material slot now when we press play you can see our enemies kind of push each other out of the way and bounce off of each other and they circle on around you can up the bounciness and mess around with the friction as much as you like to get the kind of effect you want this can sometimes work better on smaller enemies I've just set the scale a bit smaller and you can see they kind of gather around a bit more but yeah that's a quick and easy way to fake some enemy pathing around your player and make it look a little more organic and that's it nice easy tip very good I'd subscribe cool thanks bye [Music] foreign [Music]
Info
Channel: Game Code Library
Views: 1,996
Rating: undefined out of 5
Keywords: movement, beginner, top down, unity2d, game development, unity3d, player controller, development, character controller, unity tutorial, unity, top-down, controller, shoot em up, asset, how to, system, assets, controls, programming, rigidbody2d, game, move, easy, games, howto, input, basic, basics, coding, roguelike, rigidbody, video game, rogue-like, 8 direction, jam, course, develop, brackeys, enemy follow player, enemy ai unity, unity enemy movement, top down enemy, how to enemy chase player, unity enemy, ai
Id: WLg-jWxFF8w
Channel Id: undefined
Length: 2min 13sec (133 seconds)
Published: Fri Aug 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.