How can I get a mob go to a specified Location

Discussion in 'Plugin Development' started by NemesisMate, Oct 8, 2012.

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

    NemesisMate

    I'm making a plugin and I need to make a mob go to a specified location. I tried with a pathfinder so it shows like this:

    Code:
    PathfinderGoalMoveToLocation(this, location)
    But I can't find how to make it work. The only thing I want is to save the location of the mob start and after it moves to do anything he comes back to its start location (Evertytime it has nothing to do with higher priority).
     
  2. Well, if you just want it to move to a location you don't need a pathfindergoal for that.
    Either you can do:
    Code:
    <entityHandle>.getNavigation().a(inLocation.getX(), inLocation.getY(), inLocation.getZ(), <speed>);
    or, if the above code returns false, you could do this:
    Code:
    PathEntity path = <entityHandle>.world.a(<entityHandle>, MathHelper.floor(inLocation.getX()), (int) inLocation.getY(), MathHelper.floor(inLocation.getZ()), <maxRange>, true, false, false, true);
    <entityHandle>.getNavigation().a(path, <speed>);
    the booleans stand for these: 1. pass through open doors, 2. pass through closed doors (e.g. break them), 3. avoid water, 4. can swim
     
  3. Offline

    NemesisMate

    Thanx for your help, I just saw it here too: http://forums.bukkit.org/threads/mob-targetting.103322/

    I'll try it... hope it works and it's what I want.

    kumpelblase2 I tried it and it works but only when the mob appears for the first time. Once it execute another action (a pathfindergoal) the mobs stop of going to that location. What I get is:
    1. Mob appears, 2. Mob start moving to the location, 3. Mob show a target and start attacking it, 4. Mob kill target and stay in place (ignoring navigation)

    How can I make the mob restart the navigation everytime it ends the other taks?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  4. Offline

    NemesisMate

    Keyle I saw that post and I tried to understand your "MyWolf" code to make a pathfinding because I think there you make your mob move to a spcified location but... just now I can't understand it :)D I'm a little tired too, maybe because of that).

    I wanted to ask you if you know an easy way to, like the post says itself, get a mob going to an X,Y,Z coordinates. I tried it in many ways, like I say in this other post but I can't find a way to get it.

    The thing I want is the mob going (after he attacks) to a specified location so it always come back to its place. I tried with mymob.setPosition(X,Y,Z) and mymob.move(actualX-X, actualY-Y, actualZ-Z) but both methods make the mob "teleporting".

    Any idea to make them walking/running to that place instead of teleporting?

    Thanx for any help
     
  5. Offline

    Cybran

Thread Status:
Not open for further replies.

Share This Page