Pathfinding - Target nearest mob

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Donut

Well-Known Member
Mar 27, 2017
1,336
177
0
U.S.
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:
on rightclick:
    spawn a zombie at the target block's location
    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?
 
Last edited:
Hi!
If you want pathfind only nearest sheep, you need to clear all pathfind before!
code_language.skript:
clear all pathfinder goals of last spawned entity
 
I want it to pathfind to the nearest mob, no matter what it is, not just sheep.
 
So you need to use these two syntaxes:

code_language.skript:
add pathfinder goal target nearest sheep or cow or chicken... or zombie to last spawned entity
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.
 
Clearing all path before makes it do nothing.

Without clearing all path and using this:

add pathfinder goal target nearest sheep or cow or chicken... or zombie to last spawned entity

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.
 
Status
Not open for further replies.