Enemy Patrolling Unity Tutorial

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • Enjoy the video, if you have any questions ask in the comments down below!
    Request a tutorial here:
    forms.gle/JLBk...
    Patreon with fully explained c# scripts:
    / blakeygames
    Main Channel: / bblakeyyy
    Join the Discord: / discord
    Play my games! :
    blakey-games.i...
    play.google.co...
    Watch me Live on twitch: / bblakeyyy
    unity tutorial,unity,tutorial,unity 2d tutorial,unity ai tutorial,unity game tutorial,unity enemy tutorial,unity enemy ai tutorial,unity enemy ai,unity 2d,unity 2d shooting,unity tutorial 2d,unity tutorial for beginners,shooting,unity shooting,unity 2d game tutorial,unity 3d tutorial,unity enemy ai 2d,enemy,unity 3d,unity 2d shooting tutorial,unity shooting tutorial,tutorials,unity beginners tutorial,shooting tutorial in unity Audio used in my videos:
    ♪ Onion (Prod. by Lukrembo)
    Link : • (no copyright music) l...
    ♪ Branch (Prod. by Lukrembo)
    Link : • (no copyright music) c...
    ♪ Biscuit (Prod. by Lukrembo)
    Link : • (no copyright music) l...
    ♪ Bread (Prod. by Lukrembo)
    Link : • (no copyright music) j...

КОМЕНТАРІ • 21

  • @aiden1010
    @aiden1010 8 місяців тому

    For anyone having trouble with this one:
    (Did this for 2D, but should work in 3D as well)
    In the start method I had to remove ** targetPoint = 0; ** statement otherwise it would reset to 0 after reaching the first targetPoint
    In the update method
    //instead of setting the game object position to be equal to the targetPoint position set it to, if the game object is within a (very) small distance
    if (Vector2.Distance(transform.position, patrolPoints[targetPoint].position) = patrolPoints.Length)
    {
    targetPoint = 0;
    }
    }
    transform.position = Vector2.MoveTowards(transform.position, patrolPoints[targetPoint].position, speed * Time.deltaTime);

  • @OssiTov
    @OssiTov 4 місяці тому

    this is one of the best tut i`ve ever seen ty so much

  • @morebblakeyyy
    @morebblakeyyy  Рік тому +2

    Apologies for youtube compressing the darker colours in this video, super annoying that it does that!

    • @RUDERUDYTUTORIALS
      @RUDERUDYTUTORIALS Рік тому

      Its not so bad i managed to write the code down perfectly.

  • @RUDERUDYTUTORIALS
    @RUDERUDYTUTORIALS Рік тому +3

    Awesome tutorial sir. Can you please tell me how to make enemy chase player when in range of the enemy but with this function embedded thank you in advance.

  • @krishnasoni4829
    @krishnasoni4829 8 місяців тому

    Thank you very very much Sir ❣️

  • @jarrydoneill7834
    @jarrydoneill7834 Рік тому +5

    How could I combine this with a chasing mechanic, and once the player is out of reach it'll go back to patrolling?

  • @PixelNoob01
    @PixelNoob01 4 місяці тому

    Can someone help me how to draw a Gizmos Shpere for each point?

  • @Rptr797-wn4iu
    @Rptr797-wn4iu 4 місяці тому

    I'm getting an error when I use square brackets in "transform.position = vector3.movetowards(transform.position, patrolpoints[0].position, speed * time.deltatime;" can someone help
    Edit: I was using wrong variable nevermind

  • @prosealien
    @prosealien 11 місяців тому

    Very well explained but, struggling with this one with a more update unity to what I was using, watched slowly few time stops after 1st cube wondering if there is a change in new Unity, x y and z same as way points basically duplicated all steps

  • @MalicProductions
    @MalicProductions Рік тому +2

    I'm having trouble with this one. It seems as though once the enemy gets to the position of a waypoint it does not activate the
    if(transform.position == patrolPoint[targetPoint].position
    I am unsure as to why that might be, and am curious as to your thoughts.

    • @Wavero
      @Wavero Рік тому

      guessing its something to do with the Y's not being the same, think you need to check if the X and Z position of the AI is the same as the waypoints and just ignore the Y, assuming you aren't going up ramps or anything

  • @mintVal
    @mintVal Рік тому +1

    How can u make the Patrol bot returning in the same order as it came?
    not: 0,1,2 - 0,1,2
    but: 0,1,2, - 2,1,0

    • @NoobDev14
      @NoobDev14 Рік тому

      do you have the solution to this now ?

  • @killerkaneossvr5471
    @killerkaneossvr5471 Рік тому +1

    do you know how to make it so a sphere, in my case a character, look at the target points?

    • @azelwkr3841
      @azelwkr3841 Рік тому

      I'm not sure I understand but maybe you can use Transform.LookAT() function ?

    • @sweetpea2788
      @sweetpea2788 Рік тому

      lol im having the same issue because I added in an enemy FOV

  • @momoiman2677
    @momoiman2677 Рік тому +1

    does it work in 2D?