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

Solved Make mob follow player

Discussion in 'Skript' started by Runakai, May 7, 2018.

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

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Hello, me again :emoji_slight_smile: I was searching on Googlygu how to make mobs follow players. Then I found this:
    Code (Skript):
    1.  
    2. command /bass:
    3.     trigger:
    4.         spawn a pig at location of player
    5.         set the display name of the last spawned pig to "&C%player%'s Pet"
    6.         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.

     
  2. Best Answer:
    Post #18 by MusicManSK, May 10, 2018
  3. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    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
     
  4. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Hm, you're right :/ So, how may i do this :/?
    --- Double Post Merged, May 7, 2018, Original Post Date: May 7, 2018 ---
    Haha, found a way :emoji_grinning:
    Code (Skript):
    1.  
    2. command /bass:
    3.     trigger:
    4.         spawn a pig at location of player
    5.         set the display name of the last spawned pig to "&C%player%'s pet"
    6.         set the target of the last spawned pig to the player
    7.         while spawned entity exists:
    8.             make spawned entity pathfind to player with speed 1
    9.             wait 1 tick
    10.    
    11.        
    12.    
    13.    
    14.        
    15.  
    So, next question: How can i make the player control the movement of the entity :/
     
  5. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    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 (Skript):
    1. make pig pathfind to 1 block north of player at speed 1
    check this and search docs of those addons
     
  6. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    I th
    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]
    --- Double Post Merged, May 7, 2018, Original Post Date: May 7, 2018 ---
     
  7. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    maybe this
    Code (Skript):
    1. set {_loc} to block infront of player
    2. make spawned entity pathfind to {_loc} with speed 1
    3.  
    4. or this:
    5.  
    6. set {_loc} to block infront of spawned entity
    7. make spawned entity pathfind to {_loc} with speed 1
     
  8. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Nope. But now the Pig kinda seems confused. It just spins around in a circle continously
    --- Double Post Merged, May 7, 2018, Original Post Date: May 7, 2018 ---
    EDIT: Nope. It does not work and it was just my imagination that the pig walked crazy^^
     
  9. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    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
     
  10. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    So, I tried this. It does push the pig but WAY to hard. I don't know how to fix this :/

    Code (Skript):
    1.  
    2. command /bass:
    3.     trigger:
    4.         spawn a pig at location of player
    5.         set the display name of the last spawned pig to "&C%player%'s pet"
    6.         set the target of the last spawned pig to the player
    7.         make the player ride the spawned pig
    8.         while spawned entity exists:
    9.             set {_loc} to location of player
    10.             add 1 to x-coordinate of {_loc}
    11.             add 1 to z-coordinate of {_loc}
    12.             push spawned entity (direction from player to {_loc}) at speed 0.003
    13.             make spawned entity pathfind to player with speed 1
    14.    
    15.    
    16.        
    17.    
    18.    
    19.        
    20.  
     
  11. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    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"
    --- Double Post Merged, May 7, 2018, Original Post Date: May 7, 2018 ---
    maybe because you are using a loop with short delay
     
  12. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    I also put "wait 10 seconds" but it didn't change anything
     
  13. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    try the push code for a player. i can push players 1 block just fine. its maybe collision boosting the push
    --- Double Post Merged, May 8, 2018, Original Post Date: May 8, 2018 ---
    I found a topic recently where they described to turn off collision in skript.
     
  14. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    When I was running the command with the "Push player 1 block" thing in it my Server crashed. Idk why.
     
  15. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    @Runakai1 Here is your code:
    Code (Skript):
    1. command /bass:
    2.     trigger:
    3.         spawn a pig at location of player
    4.         set the display name of the spawned pig to "&b%player%&c's pet"
    5.         while spawned pig is alive:
    6.             if distance between player and spawned pig is less than 10:
    7.                 if distance between player and spawned pig is bigger than 3:
    8.                     make spawned pig pathfind to location of player with speed 1.3
    9.             else if distance between player and spawned pig is bigger than 10:
    10.                 teleport spawned pig to position of player
    11.             wait 1 tick
    12.  
    13. on right click on pig:
    14.     if name of clicked entity is "&b%player%&c's pet":
    15.         make player ride clicked entity
    16.         while vehicle of player is clicked entity:
    17.             if block infront of player's vehicle is not air or tall grass or long grass:
    18.                 if block above block infront of player's vehicle is air:
    19.                     push player's vehicle upwards at speed 0.2
    20.             push player's vehicle in horizontal direction of player at speed 0.2
    21.             wait 0.1 seconds
    Movement is little bit buggy but if you wanted it to fix i would fix it for you
     
  16. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    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 ^^
     
  17. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Yeah.. Its that buggy movement... Ill fix it when i come back to home bcs im at school now...
     
    • Winner Winner x 1
  18. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Okay, thanks :emoji_grinning:
     
  19. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Code (Skript):
    1. command /bass:
    2.     trigger:
    3.         spawn a pig at location of player
    4.         set the display name of the spawned pig to "&b%player%&c's pet"
    5.         while spawned pig is alive:
    6.             if distance between player and spawned pig is less than 10:
    7.                 if distance between player and spawned pig is bigger than 3:
    8.                     make spawned pig pathfind to location of player with speed 1.3
    9.             else if distance between player and spawned pig is bigger than 10:
    10.                 teleport spawned pig to position of player
    11.             wait 1 tick
    12.  
    13. on right click on pig:
    14.     if name of clicked entity is "&b%player%&c's pet":
    15.         make player ride clicked entity
    16.         while vehicle of player is clicked entity:
    17.             if block infront of player's vehicle is not air or tall grass or long grass:
    18.                 if block above block infront of player's vehicle is air:
    19.                     push player's vehicle upwards at speed 0.2
    20.             push player's vehicle in horizontal direction of player at speed 0.2
    21.             change yaw of vehicle of player to yaw of player
    22.             change pitch of vehicle of player to pitch of player
    23.             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 Like x 1
  20. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    Problem: SkRandom does not work when using other Addons which i need
    --- Double Post Merged, May 10, 2018, Original Post Date: May 10, 2018 ---
    Nevermind. I just updated SkRandom and now it works :emoji_slight_smile:!
     
  21. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Ok then.. Bcs i had no clue how to fix it
     
Thread Status:
Not open for further replies.

Share This Page

Loading...