Solved Set Armor Stand Velocity

Discussion in 'Plugin Development' started by Fred7767, Apr 24, 2020.

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

    Fred7767

    Code:
    ArmorStand as = location.getWorld().spawn(location, ArmorStand.class);
    
            as.setBasePlate(false);
            as.setArms(true);
            as.setVisible(visible);
            as.setRemoveWhenFarAway(true);
            as.setCanPickupItems(false);
            as.setGravity(false);
            as.setSmall(mini);
    final Vector direction = location.getDirection();
    p.sendMessage(as.getVelocity().toString());
    as.setVelocity(direction.normalize().multiply(5));
    p.sendMessage(as.getVelocity().toString());
    
    The armor stand does spawn, but it doesn't move. Why does this happen and how can if fix it?
     
    Last edited: Apr 24, 2020
  2. Offline

    bowlerguy66

    @Fred7767 Maybe you could try printing the components of the vector from the location, the armor stand before you apply the velocity, and after you apply the velocity. Unfortunately I'm not too well versed with vectors but that's what I would do if I were in that situation.
     
  3. Offline

    Fred7767

    @bowlerguy66 before: 0.0, 0.0, 0.0
    after: 1.27962, 4.041519,-2.651164
    still doesn't work
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Fred7767 Why do you work with as and the prints are for sword?
     
  5. Offline

    Fred7767

    @timtower oh yes i did wrong sorry
    but its still the same
     
  6. Offline

    timtower Administrator Administrator Moderator

    What are you trying to achieve? A moving armorstand?
     
  7. Offline

    Fred7767

  8. Offline

    timtower Administrator Administrator Moderator

    Did you consider updating the velocity every tick?
     
  9. Offline

    Fred7767

    @timtower yes i did it but it still doen't work (if you mean setting velocity by bukkitrunnable every tick)

    I found what was the problem. If you set the gravity of the armor stand false, you can't set velocity of the armor stand. Thanks for help though.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Apr 24, 2020
Thread Status:
Not open for further replies.

Share This Page