Enemy Patrolling Unity Tutorial

Поделиться
HTML-код
  • Опубликовано: 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

  • @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.

  • @OssiTov
    @OssiTov 5 месяцев назад

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

  • @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.

  • @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?

  • @aiden1010
    @aiden1010 9 месяцев назад

    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);

  • @Rptr797-wn4iu
    @Rptr797-wn4iu 5 месяцев назад

    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

  • @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

  • @PixelNoob01
    @PixelNoob01 5 месяцев назад

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

  • @krishnasoni4829
    @krishnasoni4829 9 месяцев назад

    Thank you very very much Sir ❣️

  • @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 ?

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

    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

  • @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?