Solved Trying to create a Levitating animation in an ArmorStand

Discussion in 'Spigot Plugin Development' started by HotDoctor, Nov 6, 2019.

Thread Status:
Not open for further replies.
  1. This is my code:
    Code (Java):

    public class HeadAnimation {
     
        private Main plugin;
        private ArmorStand armor;
        private double blocksdown = 2;
        private double blocksToUpAndDown = 0
        private double blocksdowned = blocksToUpAndDown;
        boolean up = false;

        public void LevitationAnimation() {
            new BukkitRunnable() {
                public void run () {
                    if (!(up)) {
                        double y = armor.getLocation().clone().getY();
                        if(blocksdowned != blocksdown) {
                            double getter = blocksdowned + 0.2;
                            blocksdowned = getter;
                            double newY = (y - 0.2);
                            armor.teleport(new Location(armor.getWorld(), armor.getLocation().getX(), newY, armor.getLocation().getZ()));
                        }
                        else if (blocksdowned == blocksdown) {
                            up = true;
                        }
                    }
                    else if(up) {
                        double y = armor.getLocation().clone().getY();
                        if(blocksdowned != 0) {
                            double getter = blocksdowned - 0.2;
                            blocksdowned = getter;
                            double newY = (y + 0.2);
                            armor.teleport(new Location(armor.getWorld(), armor.getLocation().getX(), newY, armor.getLocation().getZ()));
                        }else if(blocksdowned == 0) {
                            up = false;
                        }
                    }
               
                }
            }.runTaskTimer(plugin, 0, 3);
        }
     

    Practically when I run this code, it starts to go down, but never goes up, any help?
     
    #1 HotDoctor, Nov 6, 2019
    Last edited: Nov 6, 2019
  2. Just use something along the lines of
    Code (Text):
    yOffset = Math.sin(ticks) * 10;
    Then that'll make it bob up and down
     
  3. can you make me an example? please <3
     
  4. nevermind
    I just started to use
    (blocksdowned < blocksdown)
    and that things.

    thanks for the help
     
Thread Status:
Not open for further replies.