Solved Adding velocity from point a to point b

Discussion in 'Spigot Plugin Development' started by xlis1, May 2, 2017.

  1. Hello!

    i am trying to move an armorstand that the player is riding in a pattern, i can get the point i want to move it to as well as where it is, i cant teleport it as you cant teleport something that has a passenger (well you can kick the passenger out teleport the stand then add the passenger back but that looks extremely shaky) so i need to add velocity to the armor stand, the problem is im not good at vector math.

    this is what i have: (entity is the Armour stand)
    Code (Text):

        new BukkitRunnable() {
                double t = 0;
                double r = 1;
                public void run() {
                    t = t + Math.PI / 16;
                    double x = r * Math.cos(t);
                    double y = t;
                    double z = r * Math.sin(t);
                    loc.add(x, y, z);
                    Vector to = new Vector((entity.getLocation().getX() - loc.getX()),entity.getLocation().getY()  -         loc.getY(),entity.getLocation().getZ()  - loc.getZ());
        loc.subtract(x, y, z);
    #1 xlis1, May 2, 2017
    Last edited: May 2, 2017
    • Like Like x 1
  2. why would you need to have a player ride an armour stand? just teleport an armour stand to the player.
    Also to use the code block hit the plus symbol at the top of the editor and hit code!
  3. im trying to make a amusement park ride, and i dont want to use minecarts as i cant make them invisible and i cant use animals as i need to display a custom model wich can be achieved by placing the custom model on the armor stands head
    • Creative Creative x 1
  4. then just tp the player to the armour stand for the amount of the ride.
  5. while this would work i would like (if possible) to keep the player in the sitting animation, also constantly teleporting the player constantly locks there view.
  6. i did some testing, make an invisible pig with a name of your choosing and have the player sit in it, teleport the armour stand to the pig and move the pig, the player will stay seated.
  7. you cant teleport a entity that has a passenger, if you could i would just teleport the armor stand.
  8. Got it, just had to fix my math

    (for anyone who was having the same problem here is my code)
    Code (Text):
    Vector pos = entity.getLocation().toVector();
                    Vector target = loc.toVector();
                    Vector velocity = target.subtract(pos);
    • Useful Useful x 1