Godot 4 Enemy Ai - Patrolling Enemies and Pursuing the Player

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 12

  • @rakunana
    @rakunana  14 дней назад

    So It was brought to my attention that using "get_parent()" to climb up the tree hierarchy is bad practice, I was unaware of this, and I apologize . An easy work around (For the enemy patrol points) is to have the points as a child of the enemy by adding a Node component (NOT a Node 3d, Node3ds move with the enemy/parents). Then call down to those points instead of "get_parent(). You can set up/edit those points when you instance the enemy to your level. Then right click on the enemy and check "editable children" and you'll have access to all of the enemies children, Including the marker points. Again I apologize, I'm learning as well. Best of luck to you my children! - Raku

  • @CommunityArchiveRecords
    @CommunityArchiveRecords Месяц назад +1

    BRO! I havent watched the vid yet but im so glad you uploaded.

  • @HakanBacon
    @HakanBacon Месяц назад +1

    Thank you for making this

    • @rakunana
      @rakunana  Месяц назад +1

      Most welcome friend! Best of luck in your game endeavors!

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

    Thank you so much for this tutorial, it teached me so many new things and even gave new ideas to code. Also, why there's an error in function "direction transition" saying you can't multiply an Object and an Int? Any idea how to fix that? It triggers on (default_rot * neg_pos)

    • @rakunana
      @rakunana  Месяц назад +1

      Most welcome friend. Not sure where the error in your code is coming from. But I have the code for the entire project on my GitHub. So you can look through it. But your error says you're trying to multiply an object with an int. So I can only assume you forgot to add ".global_position " to the end of "default _rot" . "default_rot" is an object in the 3d space. We only want it's position.

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

      @@rakunana thank you, now it works, goofy, but works!

    • @rakunana
      @rakunana  Месяц назад +1

      Good to hear friend! Best of luck to you and your endeavors!

  • @BUJIGANOMEMITV
    @BUJIGANOMEMITV 20 дней назад

    The enemy is not patrolling between points, it goes to the first point and stops. Do you know what's happening?

    • @rakunana
      @rakunana  20 дней назад

      Can't tell without seeing your code but. I'm gonna assume that next position isn't being called. Is all_points[next_point_int] being added in the "target_reached" func? I do have the entire project in the description. Feel free to look through it and see if you can find the solution. Or if you can upload your code somewhere and I'll take a look to see what's going on.

    • @BUJIGANOMEMITV
      @BUJIGANOMEMITV 19 дней назад

      @@rakunana I used your code, I haven't edited anything.

    • @rakunana
      @rakunana  19 дней назад

      Did you add the signal "target_reached" from your navagent ? How many points do you have set? Is the var for next_point being called and adding + 1? A bit difficult to help without seeing your project. Even if the code is one to one. Depending on your node set up, things can still break, if different. Once more, the entire project is in the description. Feel free to download it and see where the differences are. Worst case scenario. Upload your project on GitHub, and I'll take a look at your project if you are still having trouble.