Solved Make mob follow player

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

Runakai

Supporter
Apr 27, 2018
496
32
28
21
Hello, me again :emoji_slight_smile: I was searching on Googlygu how to make mobs follow players. Then I found this:
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the last spawned pig to "&C%player%'s Pet"
        set the target of the last spawned pig to the player

Everything works exept the "Set the target..." part. My Question(s) now:
-How can i make Mobs follow Player
-How can I make Players able to control the movement of a ridden mob.
 
the problem is that a animal is not having a target (its never walking towards a player). with monster the target one will work. you could try to disguise a monster as a pig but its maybe not possible with skript. there are probably better methods
 
the problem is that a animal is not having a target (its never walking towards a player). with monster the target one will work. you could try to disguise a monster as a pig but its maybe not possible with skript. there are probably better methods
Hm, you're right :/ So, how may i do this :/?
[doublepost=1525720390,1525720229][/doublepost]
the problem is that a animal is not having a target (its never walking towards a player). with monster the target one will work. you could try to disguise a monster as a pig but its maybe not possible with skript. there are probably better methods
Haha, found a way :emoji_grinning:
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the last spawned pig to "&C%player%'s pet"
        set the target of the last spawned pig to the player
        while spawned entity exists:
            make spawned entity pathfind to player with speed 1
            wait 1 tick

So, next question: How can i make the player control the movement of the entity :/
 
i think i know how. dont know if it works but i think you can figure it out (pretty sure my expression is incorrect).
code_language.skript:
make pig pathfind to 1 block north of player at speed 1

check this and search docs of those addons
 
I th
i think i know how. dont know if it works but i think you can figure it out. I think you need to be a little creative.
code_language.skript:
make pig pathfind to 1 block north of player at speed 1

check this and search docs of those addons

I Think I have the right Addon. It does not work. I also tried:

[ODE=SKRIPT]make spawned entity pathfind to 1 block north of player at speed 1[/CODE]
[doublepost=1525721051,1525721004][/doublepost]
I th


I Think I have the right Addon. It does not work. I also tried:

code_language.skript:
make spawned entity pathfind to 1 block north of player at speed 1
 
maybe this
code_language.skript:
set {_loc} to block infront of player
make spawned entity pathfind to {_loc} with speed 1

or this:

set {_loc} to block infront of spawned entity
make spawned entity pathfind to {_loc} with speed 1
 
maybe this
code_language.skript:
set {_loc} to block infront of player
make spawned entity pathfind to {_loc} with speed 1

or this:

set {_loc} to block infront of spawned entity
make spawned entity pathfind to {_loc} with speed 1
Nope. But now the Pig kinda seems confused. It just spins around in a circle continously
[doublepost=1525721577,1525721545][/doublepost]
Nope. But now the Pig kinda seems confused. It just spins around in a circle continously
EDIT: Nope. It does not work and it was just my imagination that the pig walked crazy^^
 
you can make the pig walk towards something with a variable? make spawned entity pathfind to {variable} with speed 1?

because if that works you just need to try to make your skript to do some math. you can also try making the {_loc} 2 blocks infront of your pig or player. also try more ticks delay in your while loop.

if all that works you can look at finding a method to find the direction a player is moving towards to. you can set a variable to 1 block away from that direction. Not sure if all that is possible but you could try
 
So, I tried this. It does push the pig but WAY to hard. I don't know how to fix this :/

code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the last spawned pig to "&C%player%'s pet"
        set the target of the last spawned pig to the player
        make the player ride the spawned pig
        while spawned entity exists:
            set {_loc} to location of player
            add 1 to x-coordinate of {_loc} 
            add 1 to z-coordinate of {_loc} 
            push spawned entity (direction from player to {_loc}) at speed 0.003
            make spawned entity pathfind to player with speed 1
 
i also used the push thing today but it did not push it very hard.
try this "push spawned entity forwards at speed 0.3"
[doublepost=1525730017,1525729926][/doublepost]maybe because you are using a loop with short delay
 
i also used the push thing today but it did not push it very hard.
try this "push spawned entity forwards at speed 0.3"
[doublepost=1525730017,1525729926][/doublepost]maybe because you are using a loop with short delay
I also put "wait 10 seconds" but it didn't change anything
 
try the push code for a player. i can push players 1 block just fine. its maybe collision boosting the push
[doublepost=1525780010,1525779923][/doublepost]I found a topic recently where they described to turn off collision in skript.
 
try the push code for a player. i can push players 1 block just fine. its maybe collision boosting the push
[doublepost=1525780010,1525779923][/doublepost]I found a topic recently where they described to turn off collision in skript.
When I was running the command with the "Push player 1 block" thing in it my Server crashed. Idk why.
 
@Runakai1 Here is your code:
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the spawned pig to "&b%player%&c's pet"
        while spawned pig is alive:
            if distance between player and spawned pig is less than 10:
                if distance between player and spawned pig is bigger than 3:
                    make spawned pig pathfind to location of player with speed 1.3
            else if distance between player and spawned pig is bigger than 10:
                teleport spawned pig to position of player
            wait 1 tick

on right click on pig:
    if name of clicked entity is "&b%player%&c's pet":
        make player ride clicked entity
        while vehicle of player is clicked entity:
            if block infront of player's vehicle is not air or tall grass or long grass:
                if block above block infront of player's vehicle is air:
                    push player's vehicle upwards at speed 0.2
            push player's vehicle in horizontal direction of player at speed 0.2
            wait 0.1 seconds
Movement is little bit buggy but if you wanted it to fix i would fix it for you
 
@Runakai1 Here is your code:
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the spawned pig to "&b%player%&c's pet"
        while spawned pig is alive:
            if distance between player and spawned pig is less than 10:
                if distance between player and spawned pig is bigger than 3:
                    make spawned pig pathfind to location of player with speed 1.3
            else if distance between player and spawned pig is bigger than 10:
                teleport spawned pig to position of player
            wait 1 tick

on right click on pig:
    if name of clicked entity is "&b%player%&c's pet":
        make player ride clicked entity
        while vehicle of player is clicked entity:
            if block infront of player's vehicle is not air or tall grass or long grass:
                if block above block infront of player's vehicle is air:
                    push player's vehicle upwards at speed 0.2
            push player's vehicle in horizontal direction of player at speed 0.2
            wait 0.1 seconds
Movement is little bit buggy but if you wanted it to fix i would fix it for you
Wow, thanks! But one question: Is it possible to "turn" the pig? It's kinda crazy when going back while the pig is looking forward ^^
 
Yeah.. Its that buggy movement... Ill fix it when i come back to home bcs im at school now...
 
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the spawned pig to "&b%player%&c's pet"
        while spawned pig is alive:
            if distance between player and spawned pig is less than 10:
                if distance between player and spawned pig is bigger than 3:
                    make spawned pig pathfind to location of player with speed 1.3
            else if distance between player and spawned pig is bigger than 10:
                teleport spawned pig to position of player
            wait 1 tick
 
on right click on pig:
    if name of clicked entity is "&b%player%&c's pet":
        make player ride clicked entity
        while vehicle of player is clicked entity:
            if block infront of player's vehicle is not air or tall grass or long grass:
                if block above block infront of player's vehicle is air:
                    push player's vehicle upwards at speed 0.2
            push player's vehicle in horizontal direction of player at speed 0.2
            change yaw of vehicle of player to yaw of player
            change pitch of vehicle of player to pitch of player
            wait 0.1 seconds
Not tested but should work! You will need Addon RandomSK
Maybe you can delete "change pitch of vehicle of player to pitch of player"
 
  • Like
Reactions: Runakai
code_language.skript:
command /bass:
    trigger:
        spawn a pig at location of player
        set the display name of the spawned pig to "&b%player%&c's pet"
        while spawned pig is alive:
            if distance between player and spawned pig is less than 10:
                if distance between player and spawned pig is bigger than 3:
                    make spawned pig pathfind to location of player with speed 1.3
            else if distance between player and spawned pig is bigger than 10:
                teleport spawned pig to position of player
            wait 1 tick
 
on right click on pig:
    if name of clicked entity is "&b%player%&c's pet":
        make player ride clicked entity
        while vehicle of player is clicked entity:
            if block infront of player's vehicle is not air or tall grass or long grass:
                if block above block infront of player's vehicle is air:
                    push player's vehicle upwards at speed 0.2
            push player's vehicle in horizontal direction of player at speed 0.2
            change yaw of vehicle of player to yaw of player
            change pitch of vehicle of player to pitch of player
            wait 0.1 seconds
Not tested but should work! You will need Addon RandomSK
Maybe you can delete "change pitch of vehicle of player to pitch of player"
Problem: SkRandom does not work when using other Addons which i need
[doublepost=1525974677,1525964280][/doublepost]
Problem: SkRandom does not work when using other Addons which i need
Nevermind. I just updated SkRandom and now it works :emoji_slight_smile:!
 
Status
Not open for further replies.