Solved moving armorstand as if it was a coaster

Discussion in 'Plugin Development' started by 360_, Feb 6, 2018.

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

    360_

    So I'm trying to make an armor stand go along the coal without having to use command blocks.
    [​IMG]
    Basically, the armor stand starts at the green wool and ends at the red wool.
    I've never tried doing something like this but from looking up methods to try and do something similar to this and I've discovered that I could use Vectors (which I've never used) or I could use blender to create a path then export it, which I have no idea how to make.
    Hopefully, someone could help with this.
    Thanks in advanced
     
  2. Offline

    Zombie_Striker

    @360_
    This should be simple. Do the following:
    1. For the armorstand, store a Vector, which represents the direction it is going.
    2. Every second or so (use a BukkitRunnable for this), check the blocks around the armorstand. Store all of the blocks that are coal.
    3. Comparing the direction between where the armorstand currently is, and where the block is, turn that direction into a Vector.
    4. If the direction for the vector is similar to the vector of the armorstand, move the armorstand in that direction and set the armorstands vector equal to the direction's vector.
     
  3. Offline

    360_

    @Zombie_Striker Sorry this is a late reply but this is what I have so far
    Code:
    @EventHandler
            public void onPlayerInteract12(PlayerInteractEvent e) {
                Player p = e.getPlayer();
                if ((e.getAction() == Action.RIGHT_CLICK_AIR) && (p.getItemInHand().getType() == Material.SPONGE)) {
                    Location ride = new Location(p.getWorld(), 394.5, 4, -293);
                    ArmorStand armor1 = (ArmorStand) p.getWorld().spawnEntity(ride, EntityType.ARMOR_STAND);
                    armor1.setCustomName("§bCar");
                    armor1.setCustomNameVisible(true);
                    armor1.setPassenger(p);
                    //Main code
                    Vector vector = new Vector(1, 0, 0);
                    armor1.setVelocity(vector);
                }
            }
    The only issue i have is that if the Gravity it set to false it wont move it will just stay still
    and then this is how it looks like, https://gyazo.com/de92b94651e43abe866947fcf44680e7
     
  4. Offline

    Zombie_Striker

    @360_
    Okay, seems fine. Now all you need to follow the steps I posted above.

    And you should not set the gravity to false. I don't see the need for it, since the 'car' should always stay on the ground.
     
Thread Status:
Not open for further replies.

Share This Page