Have one object follow another...

Discussion in 'Plugin Development' started by kmccmk9, Jun 5, 2013.

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

    kmccmk9

    Hello, my goal is to create a train like plugin that actually works like a train. One way I was thinking of doing it would be to have an array of minecarts. And have a loop that tells each cart to follow the one before it. How would I tell it to do that? Any help is appreciated, thanks.
     
  2. Offline

    skore87

    Not trying to put down your idea but there is a plugin already that does this. One such example is TrainCarts.
     
  3. Offline

    kmccmk9

    There is however it does not work. And I was trying to do something a little different with a predefined length and such.
     
  4. Offline

    skore87


    The plugin specifically states that it does work with latest version, lol...
     
  5. Offline

    kmccmk9

    Correct which is why I was working on this one, which would also utilize spout for custom blocks. Mainly for my own education. So, is there a way to make an object follow another? I feel like I would need to do a lot of vector positions and teleports? Like with enemies you can set a target and they go there...
     
  6. Offline

    TheUpdater

    i used this to do when right click you aimbot on player/skeleton

    Code:
        @EventHandler
        public void onEntityRightClick(PlayerInteractEntityEvent event) {
            Player p = event.getPlayer();
            if(st == true){
                if(deat.containsKey(p)){
            Player source = event.getPlayer();
            Entity target = event.getRightClicked();
           
           
            Vector direction = getVector(target).subtract(getVector(source)).normalize();
            double x = direction.getX();
            double y = direction.getY();
            double z = direction.getZ();
           
            Location changed = source.getLocation().clone();
            changed.setYaw(360 - toDegree(Math.atan2(x, z)));
            changed.setPitch(90 - toDegree(Math.acos(y)));
            source.teleport(changed);
            if(target instanceof Zombie){
                if(deat.containsKey(p)){
                Location changed1 = source.getLocation().clone();
                changed1.setYaw(360 - toDegree(Math.atan2(x, z)));
                changed1.setPitch(120 - toDegree(Math.acos(y)));
                source.teleport(changed1);
            }
            }
            else if(target instanceof org.bukkit.entity.Skeleton){
                if(deat.containsKey(p)){
                Location changed1 = source.getLocation().clone();
                changed1.setYaw(360 - toDegree(Math.atan2(x, z)));
                changed1.setPitch(120 - toDegree(Math.acos(y)));
                source.teleport(changed1);
                }
            }
        }else{
            event.setCancelled(true);
        }
       
        }
    }
     
  7. Offline

    kmccmk9

    Interesting thanks for sharing. So this works purely off teleportation right?
     
  8. Offline

    TheUpdater

    yes if right click it teleports you so you look at player/skeleton head
     
  9. Offline

    kmccmk9

    Is there anyway to do a fluid movement?
     
  10. Offline

    TheUpdater

    add 1 block to z/z then if minecart is in that area make it look at it
    mayby just an start tho
    '
     
  11. Offline

    kmccmk9

    Interesting idea. thanks!
     
  12. Offline

    TheUpdater

    have skype? cus this sound cool i want to help if its ok

    add: tomastero
     
  13. Offline

    kmccmk9

    Sure I could always use some help.
     
Thread Status:
Not open for further replies.

Share This Page