1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pathfinding - Target nearest mob

Discussion in 'Skript' started by Donut, May 13, 2017.

Thread Status:
Not open for further replies.
  1. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    175
    Medals:
    I'm using the latest skstuff for mob pathfinding. I know how to make a mob target the nearest mob, but only of a certain type, e.g.
    Code (Text):
    1. on rightclick:
    2.     spawn a zombie at the target block's location
    3.     add pathfinder goal target nearest sheep to last spawned entity
    But is there a way to make the spawned mob target the nearest mob, no matter what type of mob it is?
     
    #1 Donut, May 13, 2017
    Last edited: May 13, 2017
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    Just replace sheep with entity.
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    That doesn't work. They don't target anything.
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    Hi!
    If you want pathfind only nearest sheep, you need to clear all pathfind before!
    Code (Skript):
    1. clear all pathfinder goals of last spawned entity
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    I want it to pathfind to the nearest mob, no matter what it is, not just sheep.
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    So you need to use these two syntaxes:

    Code (Skript):
    1. add pathfinder goal target nearest sheep or cow or chicken... or zombie to last spawned entity
    2. add pathfinder goal melee attack sheep or cow or chicken... or zombie to last spawned entity
    But I think you need to clear all path before.
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    Clearing all path before makes it do nothing.

    Without clearing all path and using this:

    makes it target multiple mobs, but it doesn't always target the closest - even if there's a cow or chicken closer than a sheep, it'll still target the sheep since sheep is listed first.
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    Hum, maybe. I never noticed the importance in the list...
    @TheBukor has the good answer :emoji_stuck_out_tongue:
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
Thread Status:
Not open for further replies.
Loading...